I'd like to use the subprocess module in the following way:
- create a new process that potentially takes a long time to execute.
- capture stdout (or stderr, or potentially both, either together or separately)
- Process data from the subprocess as it comes in, perhaps firing events on every line recieved (in wxPython say) or simply printing them out for now.
I've created processes with Popen, but if I use communicate() the data comes at me all at once, once the process has terminated.
If I create a separate thread that does a blocking readline() of myprocess.stdout (using stdout = subprocess.PIPE) I don't get any lines with this method either, until the process terminates. (no matter what I set as bufsize)
Is there a way to deal with this that isn't horrendous, and works well on multiple platforms?