subprocess.Popen stalls

mk mrkafk at gmail.com
Mon Jan 12 10:33:34 EST 2009


psaffrey at googlemail.com wrote:

> p = Popen(cmd, shell=True, bufsize=100, stdout=PIPE, stderr=PIPE)
> output = p.stdout.read()

Better use communicate() method:

standardoutputstr, standarderrorstr = subprocess.communicate(...)

Never had any problem with subprocesses when using subprocess module in 
this manner (well it's possible that standardoutputstr and/or 
standarderrorstr fill up the memory, you get the idea).

Regards,
mk






More information about the Python-list mailing list