mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-95097: fix asyncio.run
for tasks without uncancel
method (#95211)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
This commit is contained in:
parent
bceb197947
commit
54f48844d1
3 changed files with 55 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue