Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53298
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader03.nrc01.news.zen.net.uk.POSTED!not-for-mail |
|---|---|
| From | Nobody <nobody@nowhere.com> |
| Subject | Re: subprocess.Popen instance hangs |
| Date | Fri, 30 Aug 2013 15:47:27 +0100 |
| User-Agent | Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
| Message-Id | <pan.2013.08.30.14.47.27.111000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <20130829183418.GE414@mail.akwebsoft.com> <mailman.377.1377824422.19984.python-list@python.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Lines | 22 |
| Organization | Zen Internet |
| NNTP-Posting-Host | 4d936100.news.zen.co.uk |
| X-Trace | DXC=[4DJEama<PX1i>g:<=BiJQf2FgniPJjgR=dR0\ckLKGPWeZ<[7LZNRVmi`09`1fQ0]M2Z^cWRFGA[6Gm[BS\j;f_ |
| X-Complaints-To | abuse@zen.co.uk |
| Xref | csiph.com comp.lang.python:53298 |
Show key headers only | View raw
On Thu, 29 Aug 2013 17:00:21 -0800, Tim Johnson wrote: > ## This appears to be what works. > def __exec(self,args) : > """Run the process with arguments""" > p = > subprocess.Popen(args,stderr=subprocess.PIPE,stdout=subprocess.PIPE) > while 1 : > output = p.stdout.read() If the process tries to write more than a pipe's worth of data to stderr, before closing stdout, it will block indefinitely. If you want to process both stdout and stderr, you have to be able to consume the data in whatever order the process generates it, which means either using multiple threads or (on Unix) select/poll or non-blocking I/O. This is what the .communicate() method does (threads on Windows, select/poll on Unix). The alternative is to merge both streams with stderr=subprocess.STDOUT, or redirect one of them to a file (or /dev/null, etc).
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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