Problem with subprocess.Popen wget within a thread

Mathieu Prevot mathieu.prevot at gmail.com
Mon Jul 7 09:16:59 EDT 2008


2008/7/6 Sebastian lunar Wiesner <basti.wiesner at gmx.net>:
> Mathieu Prevot <mathieu.prevot at gmail.com>:
>
>> it seems the script (A) finishes before the downloading ends, and the
>> (B) version doesn't (wanted behavior) ... this is unexpected. What
>> happens ?
>
> "readlines" blocks, until the pipe is closed, which usually happens, if the
> process dies.
>
> On the other hand, spawned processes are usually asynchronous, you have to
> explicitly _wait_ for them.  And you're not waiting for it in example A.
>
> Anyway, the _proper_ way to wait for a child process is ... guess what ...
> the "wait" method of the Popen object ;)

Thanks :)
Mathieu



More information about the Python-list mailing list