subprocess.Popen instance hangs
Tim Johnson
tim at akwebsoft.com
Fri Aug 30 14:43:57 EDT 2013
* Jerry Hill <malaclypse2 at gmail.com> [130830 07:48]:
> On Fri, Aug 30, 2013 at 11:32 AM, Tim Johnson <tim at akwebsoft.com> wrote:
> > The objective is to display all output, but to also separate error
> > messages from normal output.
>
> I still think you want to use communicate(). Like this:
>
> p = subprocess.Popen(args,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
> output, err = p.communicate()
>
> That's it. No need for a loop, or manually handling the fact that
> stderr and/or stdout could end up with a full buffer and start to
> block.
The following code :
p = subprocess.Popen(args,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
errmsg,output = p.communicate()
... Hangs
this code :
p = subprocess.Popen(args,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
while 1 :
output = p.stdout.read()
if output :
print(output)
else : break
... works
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com
More information about the Python-list
mailing list