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


Groups > comp.lang.python > #43069

Re: subprocess question re waiting

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <dylan@dje.me>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'value,': 0.04; 'output': 0.05; '&quot;the': 0.07; 'alain': 0.09; 'exits': 0.09; 'received:209.85.219': 0.09; 'subject:question': 0.10; 'cc:addr :python-list': 0.11; 'command,': 0.16; 'finish.': 0.16; 'it."': 0.16; 'it.&quot;': 0.16; 'simplifies': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'users.': 0.18; 'bit': 0.19; '>>>': 0.22; 'code,': 0.22; 'email addr:gmail.com&gt;': 0.22; 'manual': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'skip:l 30': 0.24; 'mon,': 0.24; 'non': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'unix': 0.29; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; '>>>>': 0.31; 'writes:': 0.31; 'run': 0.32; 'url:python': 0.33; '"the': 0.34; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'url:library': 0.38; 'pm,': 0.38; 'does': 0.39; 'url:mail': 0.40; 'how': 0.40; 'dave': 0.60; 'first': 0.61; 'nobody': 0.68; 'angel': 0.91; 'to:none': 0.92; '2013': 0.98
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:cc:content-type:x-gm-message-state; bh=L/5hQ4Sqb6KpCVIvuHSc2Qywpiy8cRr0MKJt8y9/Ma4=; b=YVdbf+lFDDZ4jX0my8N3/MzyyOpI74/rqD32BKSTI294MhBpgboQFm+xSuSuY5Frn/ cNo//I9x1jqVCYp1Z4Sy36vZOvO4Q3BSTzFHxxW7JV24hwbw9gH/1f1a95SWa+0FamuZ dLD8TrdWdebn/rJ/O6MY/PGFWA6dnyXLzaKQZLN1hMCe19g8b88Hp7hY68yq4rmnor11 8nkAUEecn+GV40QVCmybn3CXlJ3jDvMUfEbf96FFeXV9ACHL2dbrvQOHOrKycjXooMo3 M+tZwOtUsd/mZ2+UNiiL2Uj7Iv6adZwHSeGUb7Z9nL9OlJ5zgTgerhoFTe9TupqJa3nS VoSw==
MIME-Version 1.0
X-Received by 10.182.117.131 with SMTP id ke3mr2822249obb.60.1365425900509; Mon, 08 Apr 2013 05:58:20 -0700 (PDT)
X-Originating-IP [220.245.216.139]
In-Reply-To <5162B69D.90908@davea.name>
References <ed0010ee-471d-4cbe-ae6c-1d9a172b2ffc@googlegroups.com> <8761zxdyzb.fsf@dpt-info.u-strasbg.fr> <CADQvV+vM529iuHFnEJyuuwEtQDYbg-MuY-4R7+YmbGO_HTGm4g@mail.gmail.com> <5162B69D.90908@davea.name>
Date Mon, 8 Apr 2013 22:58:20 +1000
Subject Re: subprocess question re waiting
From Dylan Evans <dylan@dje.me>
Cc python-list <python-list@python.org>
Content-Type multipart/alternative; boundary=089e0149cbfac470ca04d9d8fdca
X-Gm-Message-State ALoCoQkPIWzaJ6G34C5NvtXMNBM7PzgW9E1T2ygdlVKnI3KwP1vsp/UhbnzxCzO6HlrNIvos0qGV
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.288.1365425904.3114.python-list@python.org> (permalink)
Lines 148
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365425904 news.xs4all.nl 6890 [2001:888:2000:d::a6]:38426
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43069

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Mon, Apr 8, 2013 at 10:22 PM, Dave Angel <davea@davea.name> wrote:

> On 04/08/2013 08:01 AM, Dylan Evans wrote:
>
>> On Mon, Apr 8, 2013 at 9:48 PM, Alain Ketterlin <
>> alain@dpt-info.u-strasbg.fr
>>
>>> wrote:
>>>
>>
>>  loial <jldunn2000@gmail.com> writes:
>>>
>>>  I want to call a child process to run a shell script and wait for that
>>>> script to finish. Will the code below wait for the script to finish?
>>>> If not then how do I make it wait?
>>>>
>>> [...]
>>>
>>>> process = subprocess.Popen(command,
>>>>
>>> stdin=subprocess.PIPE,stdout=**subprocess.PIPE, stderr=subprocess.PIPE,
>>> close_fds=True, shell=True)
>>>
>>> process.wait()
>>>
>>>
>> Or use subprocess.call instead which does what you want.
>>
>>
Actually after having a look through the manual i like check_output for
this since it simplifies the code, but some extra exception handling would
be required if the output is still required when the script exits with a
non zero value, so it's a bit of a trade off.


>  -- Alain.
>>> --
>>> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>>>
>>>
>>
> http://docs.python.org/2/**library/subprocess.html#popen-**objects<http://docs.python.org/2/library/subprocess.html#popen-objects>
>
> or use communicate(), which is what the OP had in the first place.
>
>
> --
> DaveA
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>



-- 
"The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum

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


Thread

subprocess question re waiting loial <jldunn2000@gmail.com> - 2013-04-08 04:00 -0700
  Re: subprocess question re waiting Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-04-08 13:48 +0200
    Re: subprocess question re waiting Dylan Evans <dylan@dje.me> - 2013-04-08 22:01 +1000
    Re: subprocess question re waiting Dave Angel <davea@davea.name> - 2013-04-08 08:22 -0400
    Re: subprocess question re waiting Dylan Evans <dylan@dje.me> - 2013-04-08 22:58 +1000
  Re: subprocess question re waiting Dave Angel <davea@davea.name> - 2013-04-08 08:25 -0400

csiph-web