processing subprocess output line-by-line (Was: shutil.run)
On Wed, May 23, 2012 at 10:09 AM, Nick Coghlan
On Wed, May 23, 2012 at 4:49 PM, Devin Jeanpierre
wrote: On Tue, May 22, 2012 at 5:41 PM, Nick Coghlan
wrote: Having dealt with long running child processes lately, I can also say that producing output line-by-line would be on my personal list of requirements.
You can do that with subprocess, right? Just have to be sure to close stdin/stderr and read p.stdout with readline() repeatedly...
Yep, subprocess is a swiss army knife - you can do pretty much anything with it. That's the complaint, though - *because* it's so configurable, even the existing convenience APIs aren't always that convenient for simple operations.
It is quite likely that there are use cases where subprocess fails, \ because they require async control. http://bugs.python.org/issue14872 And line-by-line recipe is here: http://stackoverflow.com/questions/5582933/need-to-avoid-subprocess-deadlock... -- anatoly t.
participants (1)
-
anatoly techtonik