mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
bpo-32528: Make asyncio.CancelledError a BaseException. (GH-13528)
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
This commit is contained in:
parent
16cefb0bc7
commit
431b540bf7
16 changed files with 147 additions and 67 deletions
|
@ -1527,7 +1527,7 @@ class BaseTaskTests:
|
|||
async def sleeper():
|
||||
await asyncio.sleep(10)
|
||||
|
||||
base_exc = BaseException()
|
||||
base_exc = SystemExit()
|
||||
|
||||
async def notmutch():
|
||||
try:
|
||||
|
@ -1541,7 +1541,7 @@ class BaseTaskTests:
|
|||
task.cancel()
|
||||
self.assertFalse(task.done())
|
||||
|
||||
self.assertRaises(BaseException, test_utils.run_briefly, loop)
|
||||
self.assertRaises(SystemExit, test_utils.run_briefly, loop)
|
||||
|
||||
self.assertTrue(task.done())
|
||||
self.assertFalse(task.cancelled())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue