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


Groups > comp.lang.python > #11098

Re: subprocess.Popen and thread module

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!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.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:module': 0.04; '"""': 0.07; 'attribute.': 0.09; 'danny': 0.09; 'deprecated': 0.09; 'output': 0.10; "'-r',": 0.16; 'docs,': 0.16; 'like?': 0.16; 'parallel,': 0.16; 'returncode': 0.16; 'terminate.': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'cheers,': 0.18; 'subject:skip:s 10': 0.18; 'cc:no real name:2**0': 0.20; 'seems': 0.20; 'trying': 0.21; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'tue,': 0.23; 'pm,': 0.24; 'aug': 0.24; "i'm": 0.27; 'all,': 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'threads': 0.30; 'url:library': 0.31; 'chris': 0.32; "what's": 0.33; 'external': 0.35; 'url:python': 0.36; 'data.': 0.36; 'using': 0.37; 'but': 0.37; 'some': 0.38; 'received:google.com': 0.38; 'url:org': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'url:docs': 0.39; 'enough': 0.39; 'more': 0.60; 'your': 0.61; 'waiting': 0.63; '\xe2\x80\x93': 0.65; 'database.': 0.74; '11:48': 0.84; 'sender:addr:chris': 0.84; 'received:209.85.218.46': 0.91; 'received:mail- yi0-f46.google.com': 0.91
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 :content-transfer-encoding; bh=VTkXDr83AFrfso86Qg6eX0HRwiXAvbpCE1i1nemmtVE=; b=K2MK5m5Kposz3T85FKnxZeOfbEefOtEhVADTa6vmMHVsgby5SF3Ot4MOX6Z/N0LA9t qm4sIPYL/rK5qHJZ3kQmbTVDst/y97R1fRGL3I7J0yvBCLDaw5lu8fbRg+ZM19++UPuP njutKRHPJVR2SRGGR6OUPIY8va4UrZ9Qnts/o=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <D59C59453D0EDC43832490B6DADFAECF0432A192@XMB-RCD-214.cisco.com>
References <20110808013500.7c9e30ff44caee0f0bbf988a@johnohagan.com> <D59C59453D0EDC43832490B6DADFAECF0432A191@XMB-RCD-214.cisco.com> <CAMZYqRSxAzLaea6aR0DNDnc-Jv3XWSPvo6cZdv4D0hcL5eeKTg@mail.gmail.com> <D59C59453D0EDC43832490B6DADFAECF0432A192@XMB-RCD-214.cisco.com>
Date Tue, 9 Aug 2011 23:53:29 -0700
X-Google-Sender-Auth oeOC_mxBRnlnRMc4E46As3x-EIQ
Subject Re: subprocess.Popen and thread module
From Chris Rebert <clp2@rebertia.com>
To "Danny Wong (dannwong)" <dannwong@cisco.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc 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.2089.1312959211.1164.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312959211 news.xs4all.nl 23861 [2001:888:2000:d::a6]:38879
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11098

Show key headers only | View raw


> On Tue, Aug 9, 2011 at 11:38 PM, Danny Wong (dannwong)
> <dannwong@cisco.com> wrote:
>> Hi All,
>>   I'm trying to execute some external commands from multiple database.
>> I'm using threads and subprocess.Popen ( from docs, all the popen*
>> functions are deprecated and I was told to use subprocess.Popen) to
>> execute the external commands in parallel, but the commands seems to
>> hang.
>
> What's your Popen() call look like?

On Tue, Aug 9, 2011 at 11:48 PM, Danny Wong (dannwong)
<dannwong@cisco.com> wrote:
>    try:
>        cmd_output = subprocess.Popen(['scm', 'load', '--force', '-r', nickname, '-d', directory, project], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
>        status = cmd_output.wait()

Er, did you read the warning about Popen.wait() in the docs? (emphasis added):
"""
Popen.wait()
    Wait for child process to terminate. Set and return returncode attribute.
    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.
"""
– http://docs.python.org/library/subprocess.html#subprocess.Popen.wait

Cheers,
Chris

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


Thread

Re: subprocess.Popen and thread module Chris Rebert <clp2@rebertia.com> - 2011-08-09 23:53 -0700
  Re: subprocess.Popen and thread module Nobody <nobody@nowhere.com> - 2011-08-11 09:15 +0100

csiph-web