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
bpo-32528: Make asyncio.CancelledError a BaseException. #13528
Conversation
I see a small problem with the PR in
The test passes but a message is printed:
I suggest a little different implementation. By this, we keep exception handling logic in asyncio unchanged but put CacelledError at the proper place in exceptions hierarchy. |
This will address the common mistake many asyncio users make: an "except Exception" clause breaking Tasks cancellation. In addition to this change, we stop inheriting asyncio.TimeoutError and asyncio.InvalidStateError from their concurrent.futures.* counterparts. There's no point for these exceptions to share the inheritance chain.
python/cpython#13528 broke us in two ways: asyncio.CancelledError is no longer an alias for concurrent.futures.CancelledError and it's now a BaseException. Fixes tornadoweb#2677 Closes tornadoweb#2681
* See also: https://bugs.python.org/issue32528 * This change makes actxmgr cancellation behaviors in Python 3.6/3.7/3.8 consistent.
This will address the common mistake many asyncio users make: an "except Exception" clause breaking Tasks cancellation. In addition to this change, we stop inheriting asyncio.TimeoutError and asyncio.InvalidStateError from their concurrent.futures.* counterparts. There's no point for these exceptions to share the inheritance chain. In 3.9 we'll focus on implementing supervisors and cancel scopes, which should allow better handling of all exceptions, including SystemExit and KeyboardInterrupt
…or (GH-21474) #msg373510 [bpo-32528]()/#13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1
…or (pythonGH-21474) GH-msg373510 [bpo-32528]()/pythonGH-13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1 (cherry picked from commit 2a51818) Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com>
…or (pythonGH-21474) GH-msg373510 [bpo-32528]()/pythonGH-13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1 (cherry picked from commit 2a51818) Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com>
…or (GH-21474) GH-msg373510 [bpo-32528]()/GH-13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1 (cherry picked from commit 2a51818) Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com>
…or (pythonGH-21474) #msg373510 [bpo-32528]()/python#13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1
…or (pythonGH-21474) GH-msg373510 [bpo-32528]()/pythonGH-13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1 (cherry picked from commit 2a51818) Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com>
…or (GH-21474) GH-msg373510 [bpo-32528]()/GH-13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1 (cherry picked from commit 2a51818) Co-authored-by: JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com>
* fix for 3.8 python pull 13528 - python/cpython#13528 * changes * flake8
* fix for 3.8 python pull 13528 - python/cpython#13528 * changes * flake8
…or (pythonGH-21474) #msg373510 [bpo-32528]()/python#13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1
…or (pythonGH-21474) #msg373510 [bpo-32528]()/python#13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1
…or (pythonGH-21474) #msg373510 [bpo-32528]()/python#13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1
…or (pythonGH-21474) #msg373510 [bpo-32528]()/python#13528 changed `asyncio.CancelledError` such that it no longer inherits from `concurrent.futures.CancelledError`. As this affects existing code, specifically when catching the latter instead of the former in exception handling, it should be documented in the "What's new in 3.8?" document. Automerge-Triggered-By: @1st1
This will address the common mistake many asyncio users make:
an "except Exception" clause breaking Tasks cancellation.
In addition to this change, we stop inheriting asyncio.TimeoutError
and asyncio.InvalidStateError from their concurrent.futures.*
counterparts. There's no point for these exceptions to share the
inheritance chain.
https://bugs.python.org/issue32528