mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
GH-95097: fix asyncio.run for tasks without uncancel method (GH-95211) (GH-95387)
(cherry picked from commit 54f48844d1)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
This commit is contained in:
parent
c26470f0cc
commit
efeda8b4a1
3 changed files with 55 additions and 6 deletions
|
|
@ -119,10 +119,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