bpo-33110: Catches errors raised when running add_done_callback on already completed futures.#13141
bpo-33110: Catches errors raised when running add_done_callback on already completed futures.#13141pitrou merged 3 commits intopython:masterfrom martsa1:futures-fix
Conversation
…ready completed futures. Wraps the callback call within the `add_done_callback` function within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed.
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
|
CLA has been signed, hopefully will propagate through shortly. |
Misc/NEWS.d/next/Library/2019-05-06-22-34-47.bpo-33110.rSJSCh.rst
Outdated
Show resolved
Hide resolved
|
The previous behavior was a bug. This fix also seems reasonably safe because the pre-PR behavior is timing dependent anyway. |
|
LGTM. You'll need a committer review. |
|
Thanks @ABitMoreDepth for the PR, and @pitrou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
|
Thanks @ABitMoreDepth for the PR, and @pitrou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6. |
…ady completed futures (pythonGH-13141) Wrap the callback call within the `add_done_callback` function within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed. (cherry picked from commit 2a3a2ec) Co-authored-by: Sam Martin <ABitMoreDepth@users.noreply.github.com>
|
GH-13508 is a backport of this pull request to the 3.7 branch. |
|
GH-13509 is a backport of this pull request to the 3.6 branch. |
…ady completed futures (pythonGH-13141) Wrap the callback call within the `add_done_callback` function within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed. (cherry picked from commit 2a3a2ec) Co-authored-by: Sam Martin <ABitMoreDepth@users.noreply.github.com>
…ady completed futures (GH-13141) Wrap the callback call within the `add_done_callback` function within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed. (cherry picked from commit 2a3a2ec) Co-authored-by: Sam Martin <ABitMoreDepth@users.noreply.github.com>
Wraps the callback call within the
add_done_callbackfunction within concurrent.futures, in order to behave in an identical manner to callbacks added to a running future are triggered once it has completed.Prior to this change, adding a callback to a future which has already completed, which raises, will allow that exception to raise, where running that callback later (i.e. once a future completes), wraps the callback execution in a
try..exceptstatement. This pull request matches that behavior for callbacks added to an already complete future.I feel this brings the
add_done_callbackbehavior inline with the documentation. I have added a unit test alongside this change which demonstrates the behavior.Please let me know if there's anything I need to tweak here etc.
https://bugs.python.org/issue33110