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


Groups > comp.lang.python > #53251

Re: subprocess.Popen instance hangs

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.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; 'method.': 0.07; 'subject:skip:s 10': 0.07; 'output,': 0.09; 'solution,': 0.09; 'subject:instance': 0.09; 'python': 0.11; "(you're": 0.16; 'argument,': 0.16; 'argument.': 0.16; 'blocks': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'googled': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'stdout': 0.16; 'tempfile': 0.16; 'wrote:': 0.18; 'finished': 0.19; 'header:User-Agent:1': 0.23; 'sort': 0.25; "i've": 0.25; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; "i'm": 0.30; 'code': 0.31; 'follows': 0.31; 'option.': 0.31; 'skip:s 70': 0.31; 'terminate': 0.31; 'file': 0.32; 'option': 0.32; 'open': 0.33; 'could': 0.34; 'johnson': 0.35; 'received:84': 0.35; 'but': 0.35; 'found.': 0.36; 'done': 0.36; 'should': 0.36; 'so,': 0.37; 'handle': 0.38; 'to:addr :python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'managing': 0.66; 'header:Reply- To:1': 0.67; 'brain': 0.68; 'reply-to:no real name:2**0': 0.71; 'surprise': 0.74; 'topic,': 0.81; '2.7.1': 0.84; 'examples.': 0.84; 'reply-to:addr:python.org': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=ZMDuxxLb c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=KwjEqeNB9tEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=zRnySXMCijIA:10 a=qCPAsA0v81LYdTO8F5kA:9 a=wPNLvfGTeEIA:10
X-AUTH mrabarnett:2500
Date Thu, 29 Aug 2013 20:01:56 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version 1.0
To python-list@python.org
Subject Re: subprocess.Popen instance hangs
References <20130829183418.GE414@mail.akwebsoft.com>
In-Reply-To <20130829183418.GE414@mail.akwebsoft.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
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.368.1377802908.19984.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377802908 news.xs4all.nl 15949 [2001:888:2000:d::a6]:37893
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53251

Show key headers only | View raw


On 29/08/2013 19:34, Tim Johnson wrote:
> using Python 2.7.1 on OS X 10.7.5
>
> I'm managing a process of drush using an instance of subprocess.Popen
>
> The process has a '--verbose' option. When that option is passed as
> part of the initializer `args' argument, the process will hang.
>
> It should be no surprise as drush output with the --verbose option
> can be _extremely_ verbose, and I can do without it, but I would
> like to learn how to handle it. I've googled this topic, but my poor
> little brain is yet to sort out all of the content found.
>
> ## my relevant code follows :
> p = subprocess.Popen(args,stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
> ## wait() is 'forever' if '--verbose' used
> exit_status = p.wait()
> output = p.stdout.read()
> ## done
>
> I 'suspect' that using a tempfile may be the solution, if so, I
> could use some examples.
>
The subprocess will terminate when it has finished writing its output,
but because you're not consuming any of the output (you're waiting for
it to finish), the buffer fills up and blocks the subprocess.

Try reading the output or using the .communicate method.

Alternatively, pass an open file as the stdout argument.

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


Thread

Re: subprocess.Popen instance hangs MRAB <python@mrabarnett.plus.com> - 2013-08-29 20:01 +0100

csiph-web