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


Groups > comp.lang.python > #53302

Re: subprocess.Popen instance hangs

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <malaclypse2@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'subject:skip:s 10': 0.07; 'output,': 0.09; 'subject:instance': 0.09; '11:32': 0.16; 'block.': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'separate': 0.22; 'error': 0.23; 'handling': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'fri,': 0.33; 'could': 0.34; 'display': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:s 60': 0.36; 'to:addr:python- list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'manually': 0.60; 'full': 0.61; '30,': 0.65; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=G9f1ffexg+w8kUgLRi3I5M/ribRPa2KK5WFRwmbyPrs=; b=k2rwdwZu1/nkYGua/cTqbUJ9cAtbs7qcEvjmpH7vBXE+5k2nvHcmnv8Vlz2Ecq0ctO 5+bS7j8gqUcpVNre97Yy4ieK8Nx3UMwTaX9qA+1F5tNjSYhSZoHEJd0TjaffRZqndx7n S24rm8y33jVGXcisXgJbOaSyFkD2jtMaFpTLGuHllitPflvQpHz2wuR47vGXxfg6tJ+Y KRTrbjDtoW5ycq5TwDvehLDF49QlI5Yy3iRzolzMOurKlybt2pxmkHT8NS5EkHQ9O3LP 3J3XBlx7TRMhTv6x3yFmqELgp6kjtOSWi1B5KESBqrWxoo1mx62MaG6PCzMQmCtKzQKv mtJw==
MIME-Version 1.0
X-Received by 10.66.219.233 with SMTP id pr9mr11531063pac.45.1377877138434; Fri, 30 Aug 2013 08:38:58 -0700 (PDT)
In-Reply-To <20130830153229.GC400@mail.akwebsoft.com>
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>
Date Fri, 30 Aug 2013 11:38:58 -0400
Subject Re: subprocess.Popen instance hangs
From Jerry Hill <malaclypse2@gmail.com>
To "python-list (General)" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.391.1377877489.19984.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377877489 news.xs4all.nl 15977 [2001:888:2000:d::a6]:32815
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53302

Show key headers only | View raw


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.

-- 
Jerry

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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