-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-136655: ensure cancelled futures are notified on process pool shutdown #140021
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
base: main
Are you sure you want to change the base?
Conversation
…l shutdown At present when a process pool executor shuts down it is cancelling pending work items, but failing to notify any waiting threads. Fix this. See also pythongh-109934, which is a similar bug in the thread pool executor.
Your tests failed in MacOSX and Ubuntu, perhaps because there is a barrier that indefinitly waits for - It's strongly possible that a future is cancelled or never starts, and so on never calls the |
Thanks, but I am aware the tests failed. I am currently investigating/debugging, but haven't had a lot of time to spend on it over the last few days. I've managed to reproduce the failure locally now, so will hopefully start to make progress. I think there is something more subtle than just an indefinite The proposed unit test is functionally similar to the example from the issue, but attempts to use barriers instead of arbitrary sleep delays so as to work reliably independent of timing. Obviously it isn't there yet, but I'm not a fan of using sleeps to try and hit timing windows, so intend to persevere with this approach for now. |
… prima facie unrelated unit test failure/hang.
Another interesting thing about this failure is that it seems to be new: it did not occur in the #134618 PR (the other fix in there "should" not be relevant to this failure). I've confirmed that now on my local system, and have bisected the introduction of the failure to #136796. Which suggests a fix, and indeed adding a |
At present when a process pool executor shuts down it is cancelling pending work items, but failing to notify any waiting threads. Fix this.
See also gh-109934, which is a similar bug in the thread pool executor.
ProcessPoolExecutor
fails to notify when called withshutdown(cancel_futures=True)
#136655