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


Groups > comp.lang.python > #43069

Re: subprocess question re waiting

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 2013-04-08 22:58 +1000
Subject Re: subprocess question re waiting
From Dylan Evans <dylan@dje.me>
Newsgroups comp.lang.python
Message-ID <mailman.288.1365425904.3114.python-list@python.org> (permalink)

Show all headers | 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