diff options
Diffstat (limited to 'Lib/asyncio/runners.py')
-rw-r--r-- | Lib/asyncio/runners.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/asyncio/runners.py b/Lib/asyncio/runners.py index 7489a50..a8b74d5 100644 --- a/Lib/asyncio/runners.py +++ b/Lib/asyncio/runners.py @@ -118,10 +118,11 @@ class Runner: events.set_event_loop(self._loop) return self._loop.run_until_complete(task) except exceptions.CancelledError: - if self._interrupt_count > 0 and task.uncancel() == 0: - raise KeyboardInterrupt() - else: - raise # CancelledError + if self._interrupt_count > 0: + uncancel = getattr(task, "uncancel", None) + if uncancel is not None and uncancel() == 0: + raise KeyboardInterrupt() + raise # CancelledError finally: if (sigint_handler is not None and signal.getsignal(signal.SIGINT) is sigint_handler |