[Python-ideas] processing subprocess output line-by-line (Was: shutil.run)

anatoly techtonik techtonik at gmail.com
Wed May 23 11:07:55 CEST 2012


On Wed, May 23, 2012 at 10:09 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Wed, May 23, 2012 at 4:49 PM, Devin Jeanpierre
> <jeanpierreda at gmail.com> wrote:
>> On Tue, May 22, 2012 at 5:41 PM, Nick Coghlan <ncoghlan at gmail.com> 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-without-communicate
--
anatoly t.



More information about the Python-ideas mailing list