Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11195
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: subprocess.Popen and thread module |
| Date | 2011-08-11 09:15 +0100 |
| Message-Id | <pan.2011.08.11.08.15.12.752000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <20110808013500.7c9e30ff44caee0f0bbf988a@johnohagan.com> <D59C59453D0EDC43832490B6DADFAECF0432A191@XMB-RCD-214.cisco.com> <CAMZYqRSxAzLaea6aR0DNDnc-Jv3XWSPvo6cZdv4D0hcL5eeKTg@mail.gmail.com> <D59C59453D0EDC43832490B6DADFAECF0432A192@XMB-RCD-214.cisco.com> <mailman.2089.1312959211.1164.python-list@python.org> |
| Organization | Zen Internet |
Danny Wong (dannwong) <dannwong@cisco.com> wrote: > cmd_output = subprocess.Popen(['scm', 'load', '--force', > '-r', nickname, '-d', directory, project], stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > status = cmd_output.wait() If you redirect stdout and/or stderr to a pipe, you must wait for EOF before calling wait(), otherwise you risk deadlock (the process blocks waiting for Python to read data from the pipe while Python is blocked waiting for the process to terminate). And if you redirect both stdout and stderr to pipes, you must either use multiple threads or non-blocking I/O, otherwise you risk deadlock (the process blocks waiting for Python to read data from one of the pipes while Python is blocked waiting for the process to write to the other pipe). I suggest looking at the .communicate() method of the Popen class.
Back to comp.lang.python | Previous | Next — Previous 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