Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11098
| References | <20110808013500.7c9e30ff44caee0f0bbf988a@johnohagan.com> <D59C59453D0EDC43832490B6DADFAECF0432A191@XMB-RCD-214.cisco.com> <CAMZYqRSxAzLaea6aR0DNDnc-Jv3XWSPvo6cZdv4D0hcL5eeKTg@mail.gmail.com> <D59C59453D0EDC43832490B6DADFAECF0432A192@XMB-RCD-214.cisco.com> |
|---|---|
| Date | 2011-08-09 23:53 -0700 |
| Subject | Re: subprocess.Popen and thread module |
| From | Chris Rebert <clp2@rebertia.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2089.1312959211.1164.python-list@python.org> (permalink) |
> 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 | Next — Next in thread | Find similar | Unroll 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