summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/exceptions.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2019-05-27 12:45:12 (GMT)
committerGitHub <noreply@github.com>2019-05-27 12:45:12 (GMT)
commit431b540bf79f0982559b1b0e420b1b085f667bb7 (patch)
tree2e7027339ce786cc90e04cba1b03c71ecf38dfda /Lib/asyncio/exceptions.py
parent16cefb0bc7b05c08caf08525398ff178c35dece4 (diff)
downloadcpython-431b540bf79f0982559b1b0e420b1b085f667bb7.zip
cpython-431b540bf79f0982559b1b0e420b1b085f667bb7.tar.gz
cpython-431b540bf79f0982559b1b0e420b1b085f667bb7.tar.bz2
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
Diffstat (limited to 'Lib/asyncio/exceptions.py')
-rw-r--r--Lib/asyncio/exceptions.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/asyncio/exceptions.py b/Lib/asyncio/exceptions.py
index cac31a5..e03602e 100644
--- a/Lib/asyncio/exceptions.py
+++ b/Lib/asyncio/exceptions.py
@@ -5,19 +5,16 @@ __all__ = ('CancelledError', 'InvalidStateError', 'TimeoutError',
'IncompleteReadError', 'LimitOverrunError',
'SendfileNotAvailableError')
-import concurrent.futures
-from . import base_futures
-
-class CancelledError(concurrent.futures.CancelledError):
+class CancelledError(BaseException):
"""The Future or Task was cancelled."""
-class TimeoutError(concurrent.futures.TimeoutError):
+class TimeoutError(Exception):
"""The operation exceeded the given deadline."""
-class InvalidStateError(concurrent.futures.InvalidStateError):
+class InvalidStateError(Exception):
"""The operation is not allowed in this state."""