diff options
| author | Yury Selivanov <yury@magic.io> | 2019-05-27 12:45:12 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-27 12:45:12 (GMT) |
| commit | 431b540bf79f0982559b1b0e420b1b085f667bb7 (patch) | |
| tree | 2e7027339ce786cc90e04cba1b03c71ecf38dfda /Lib/asyncio/transports.py | |
| parent | 16cefb0bc7b05c08caf08525398ff178c35dece4 (diff) | |
| download | cpython-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/transports.py')
| -rw-r--r-- | Lib/asyncio/transports.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/asyncio/transports.py b/Lib/asyncio/transports.py index 233bbb5..47b37fa 100644 --- a/Lib/asyncio/transports.py +++ b/Lib/asyncio/transports.py @@ -262,7 +262,9 @@ class _FlowControlMixin(Transport): self._protocol_paused = True try: self._protocol.pause_writing() - except Exception as exc: + except (SystemExit, KeyboardInterrupt): + raise + except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.pause_writing() failed', 'exception': exc, @@ -276,7 +278,9 @@ class _FlowControlMixin(Transport): self._protocol_paused = False try: self._protocol.resume_writing() - except Exception as exc: + except (SystemExit, KeyboardInterrupt): + raise + except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.resume_writing() failed', 'exception': exc, |
