Subprocess does not return for longer-running process

Chris Rebert clp2 at
Wed Sep 22 02:33:25 CEST 2010

On Tue, Sep 21, 2010 at 3:06 PM, Jason Friedman <jsf80238 at> wrote:
> Hello,
> The Popen call does not return if the underlying OS call runs longish,
> as the example below shows.
> wikiuser at dvprwiki1:~> time $HOME/scripts/
> "/opt/confluence-cli-1.5.0/ --action getPageList --space
> Oncall --user cli --password cli" | head -1
> Traceback (most recent call last):
>   File "$HOME/scripts/", line 18, in <module>
>     execute(sys.argv[1].split())
>   File "$HOME/scripts/", line 9, in execute
>     (pid, exit_code) = os.waitpid(, 0)
> KeyboardInterrupt
> real    1m25.306s
> user    0m0.021s
> sys     0m0.035s
> (Note I killed this last command with CNTL-C.)

As your Traceback clearly indicates, the Popen() call has already
completed; it's *the os.waitpid() call* that's blocking, but that's
entirely to be expected given its defined behavior. If you don't want
to wait around for the process to die, then don't call waitpid() on it
in the first place!


More information about the Python-list mailing list