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


Groups > comp.lang.python > #8631

Re: Trying to chain processes together on a pipeline

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.036
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'warnings': 0.05; 'does.': 0.07; 'output': 0.11; 'examples': 0.12; 'am,': 0.13; 'wrote:': 0.15; 'deadlock': 0.16; 'stdout': 0.16; 'subject:Trying': 0.16; 'cc:addr:python-list': 0.16; 'cheers,': 0.19; 'slightly': 0.19; 'cc:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'fri,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.30; 'blocks': 0.30; 'setup,': 0.30; 'strings.': 0.30; 'chris': 0.32; 'andrew': 0.32; 'instead': 0.34; "can't": 0.34; 'pretty': 0.35; 'explain': 0.36; 'data.': 0.36; 'but': 0.37; 'using': 0.37; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'two': 0.38; 'data': 0.39; 'received:209': 0.40; "i'd": 0.40; 'give': 0.60; 'your': 0.60; 'peter': 0.62; 'waiting': 0.62; 'respect.': 0.67; 'otten': 0.84; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=cEXM66Ck7TvYlaihZ3CPNe6GjkSgtt207MZ49Ok3zAs=; b=Rbrnhpf1liws6G5qA6ztIMG2nwiGGiRFE8CQXVHIf6Y03t38w6nirnRcCiE1uAC/f+ KdxdDHFmNbfOANLNEusgviWPLBrzNjddimIE7dxMdQoie1ZxKUNYsSE+JcY+VTXAHhL2 kd7oVrZCaucyHMjH21lyIcYIe6ZUy5MsGjJgc=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <4E0D7F08.4080207@gmail.com>
References <4E096D3B.3080300@gmail.com> <iubshf$dus$1@dough.gmane.org> <mailman.532.1309484420.1164.python-list@python.org> <iujsrg$qe3$1@solani.org> <4E0D7F08.4080207@gmail.com>
Date Fri, 1 Jul 2011 01:24:50 -0700
X-Google-Sender-Auth dZP3yOTZUQxaGeD2IXlDJ9wdD-0
Subject Re: Trying to chain processes together on a pipeline
From Chris Rebert <clp2@rebertia.com>
To Andrew Berg <bahamutzero8825@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc "comp.lang.python" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.539.1309508695.1164.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1309508695 news.xs4all.nl 21759 [2001:888:2000:d::a6]:46020
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8631

Show key headers only | View raw


On Fri, Jul 1, 2011 at 1:02 AM, Andrew Berg <bahamutzero8825@gmail.com> wrote:
> On 2011.07.01 02:26 AM, Peter Otten wrote:
>> I can't reproduce your setup, but I'd try using communicate() instead of
>> wait() and close().
> I don't really know what communicate() does.

"Read data from stdout and stderr, until end-of-file is reached. Wait
for process to terminate."
It then returns the read data as two strings. It's pretty straightforward.

> The docs don't give much
> info or any examples (that explain communicate() anyway), and don't say
> when communicate() is useful.

They are slightly roundabout in that respect. The warnings for .wait()
and .stdout/err explain communicate()'s utility:
"Warning: This will deadlock when using stdout=PIPE and/or stderr=PIPE
and the child process generates enough output to a pipe such that it
blocks waiting for the OS pipe buffer to accept more data. ***Use
communicate() to avoid that.***" [emphasis added]

Cheers,
Chris
--
http://rebertia.com

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


Thread

Re: Trying to chain processes together on a pipeline Andrew Berg <bahamutzero8825@gmail.com> - 2011-06-30 20:40 -0500
  Re: Trying to chain processes together on a pipeline Peter Otten <__peter__@web.de> - 2011-07-01 09:26 +0200
    Re: Trying to chain processes together on a pipeline Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-01 03:02 -0500
    Re: Trying to chain processes together on a pipeline Chris Rebert <clp2@rebertia.com> - 2011-07-01 01:24 -0700

csiph-web