Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53301
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <tim@akwebsoft.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'output': 0.05; 'subject:skip:s 10': 0.07; 'tries': 0.07; 'etc).': 0.09; 'merging': 0.09; 'output,': 0.09; 'subject:instance': 0.09; 'windows,': 0.09; 'works.': 0.09; 'def': 0.12; 'forty': 0.16; 'non-blocking': 0.16; 'stdout': 0.16; 'them...': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'appears': 0.22; 'aug': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'merge': 0.24; 'earlier': 0.24; '(or': 0.24; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'code': 0.31; '(on': 0.31; 'file': 0.32; 'skip:_ 10': 0.34; 'display': 0.35; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'skip:s 60': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'thank': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'content-disposition:inline': 0.62; 'more': 0.64; 'worth': 0.66; 'nobody': 0.68; 'said:': 0.68; 'etc..': 0.84; 'streams': 0.84; '2013': 0.98 |
| Date | Fri, 30 Aug 2013 07:32:29 -0800 |
| From | Tim Johnson <tim@akwebsoft.com> |
| To | python-list@python.org |
| Subject | Re: subprocess.Popen instance hangs |
| Mail-Followup-To | python-list@python.org |
| References | <20130829183418.GE414@mail.akwebsoft.com> <mailman.377.1377824422.19984.python-list@python.org> <pan.2013.08.30.14.47.27.111000@nowhere.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| In-Reply-To | <pan.2013.08.30.14.47.27.111000@nowhere.com> |
| User-Agent | Mutt/1.4.2.3i |
| Organization | AkWebsoft |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.390.1377876752.19984.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377876752 news.xs4all.nl 15997 [2001:888:2000:d::a6]:57457 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53301 |
Show key headers only | View raw
* Nobody <nobody@nowhere.com> [130830 06:55]: > 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). In earlier code I, I was merging them... :) Like I said: gnarly! What if I were to do something like: ## code while 1: output = p.stout.read() err = p.stderr.read() ## trapping for AttributeError, etc.. .... ## /code break'ing if either no output or value in `err' ?? The objective is to display all output, but to also separate error messages from normal output. thank you -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com
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