New submission from Josh Cogliati <[EMAIL PROTECTED]>: I was trying to use subprocess to run multiple processes, and then wait until one was finished. I was using poll() to do this and created the following test case: #BEGIN import subprocess,os
procs = [subprocess.Popen(["sleep",str(x)]) for x in range(1,11)] while len(procs) > 0: os.wait() print [(p.pid,p.poll()) for p in procs] procs = [p for p in procs if p.poll() == None] #END I would have expected that as this program was run, it would remove the processes that finished from the procs list, but instead, they stay in it and I got the following output: #Output [(7426, None), (7427, None), (7428, None), (7429, None), (7430, None), (7431, None), (7432, None), (7433, None), (7434, None), (7435, None)] #above line repeats 8 more times [(7426, None), (7427, None), (7428, None), (7429, None), (7430, None), (7431, None), (7432, None), (7433, None), (7434, None), (7435, None)] Traceback (most recent call last): File "./test_poll.py", line 9, in <module> os.wait() OSError: [Errno 10] No child processes #End output Basically, even for finished processes, poll returns None. Version of python used: Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2 Relevant documentation in Library reference manual 17.1.2 poll( ) ... Returns returncode attribute. ... A None value indicates that the process hasn't terminated yet. ---------- messages: 64439 nosy: jjcogliati severity: normal status: open title: Popen.poll always returns None type: behavior versions: Python 2.5 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2475> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com