Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53311

Re: subprocess.Popen instance hangs

Date 2013-08-30 10:43 -0800
From Tim Johnson <tim@akwebsoft.com>
Subject Re: subprocess.Popen instance hangs
References <20130829183418.GE414@mail.akwebsoft.com> <mailman.377.1377824422.19984.python-list@python.org> <pan.2013.08.30.14.47.27.111000@nowhere.com> <20130830153229.GC400@mail.akwebsoft.com> <CADwdpyae+hQHbyFTHTOK-SvNkNazPBeSyq2WQ3mwsajCDWY67w@mail.gmail.com>
Organization AkWebsoft
Newsgroups comp.lang.python
Message-ID <mailman.396.1377888246.19984.python-list@python.org> (permalink)

Show all headers | View raw


* Jerry Hill <malaclypse2@gmail.com> [130830 07:48]:
> On Fri, Aug 30, 2013 at 11:32 AM, Tim Johnson <tim@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: subprocess.Popen instance hangs Tim Johnson <tim@akwebsoft.com> - 2013-08-29 17:00 -0800
  Re: subprocess.Popen instance hangs Nobody <nobody@nowhere.com> - 2013-08-30 15:47 +0100
    Re: subprocess.Popen instance hangs Tim Johnson <tim@akwebsoft.com> - 2013-08-30 07:32 -0800
    Re: subprocess.Popen instance hangs Jerry Hill <malaclypse2@gmail.com> - 2013-08-30 11:38 -0400
    Re: subprocess.Popen instance hangs Tim Johnson <tim@akwebsoft.com> - 2013-08-30 10:43 -0800

csiph-web