New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Popen.poll always returns None #46727
Comments
I was trying to use subprocess to run multiple processes, and then wait 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 #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: Relevant documentation in Library reference manual 17.1.2 |
The problem is that os.wait() does not play nicely with subprocess.py. You can (sort of) fix your program by using Maybe a subprocess.wait() function could be added which would return a
where popen_object is None if the process is "foreign" (i.e. it was It would not be hard to implement this on unix if you don't care about To implement something similar on windows you would probably need to |
Hm. Well, after filing the bug, I created a thread for each subprocess, |
Isn't this a critical problem. The .poll() function serves as a means to Maybe I'm miss applying the .poll() function. I'm trying to detect that Thanks, Mike |
I have also run into this problem. If you only use p.poll() and never roudkerk's workaround doesn't seem to work with the new Popen objects, |
Should this be closed or is this still a problem in 2.7 (release candidate out now, final soon) or 3.1? |
Terry, I had long since coded around the problem. At this point, I no longer have On Wed, Jun 16, 2010 at 8:13 PM, Terry J. Reedy <report@bugs.python.org>wrote:
|
This issue is still alive and well for me. I'm running Python 3.10.13 on Apple Silicon Mac. I'm sending A workaround that works: using A potential complication is that I'm running all of this from a signal handler or an I tried using Can I suggest reopening this and actually fixing the behaviour of |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: