Execute code after death of all child processes - (corrected posting)

Denis S. Otkidach ods at strana.ru
Tue Dec 28 16:35:00 CET 2004


On Sat, 25 Dec 2004 08:20:24 -0600
Jeff Epler <jepler at unpythonic.net> wrote:

> Next, you'll want to wait for each process you started:
>     for current_text in texts:
>         os.waitpid(-1, 0)
>     print 'this is the end'

This can eventually die with exception.  The proper way is:

    try:
        while True:
            os.waitpid(-1, 0)
    except OSError, exc:
        if exc.errno!=errno.ECHILD:
            raise

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]



More information about the Python-list mailing list