Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 104293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:15:31+00:00 2026-05-11T01:15:31+00:00

In the python program I’m writing, I’ve got a thread which iterates over a

  • 0

In the python program I’m writing, I’ve got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I’ve got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread will be buffered for the second?

Specifically, I’m trying to pass data to subprocess.Popen(). The process will read from stdin, but you cannot pass a ‘file-like’ object to Popen because it calls stdin.fileno() and blows up unless you have a real file.

Instead, you need to pass the PIPE argument to Popen, which allows you to use proc.stdin as a file-like object. But if you’ve already got a file-like object, there doesn’t seem to be a great way to yolk the two of them together.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:15:32+00:00Added an answer on May 11, 2026 at 1:15 am

    Use shutil‘s copyfileobj() function:

    import shutil import subprocess  proc = subprocess.Popen([...], stdin=subprocess.PIPE)  my_input = get_filelike_object('from a place not given in the question')  shutil.copyfileobj(my_input, proc.stdin) 

    No need to use threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 60k
  • Answers 60k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The problem is that the Message property is calling itself.… May 11, 2026 at 9:30 am
  • added an answer Applets are usually slow, horrible, inappropriate in a browser, can't… May 11, 2026 at 9:30 am
  • added an answer Templates are a very powerful mechanism which can simplify many… May 11, 2026 at 9:30 am

Related Questions

In the python program I'm writing, I've got a thread which iterates over a
I'm using the python optparse module in my program, and I'm having trouble finding
I have embedded a Python interpreter in a C program. Suppose the C program
in my python program to upload a file to the internet, im using a
In the Python documentation it says: A thread can be flagged as a daemon
After these instructions in the Python interpreter one gets a window with a plot:
What is the difference between the search() and match() functions in the Python re
I'm interested in how much up front validation people do in the Python they
I was looking at the builtin object methods in the Python documentation , and
I am aware of how to setup autocompletion of python objects in the python

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.