mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-105836: Fix asyncio.run_coroutine_threadsafe leaving underlying cancelled asyncio task running (#141696)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
56a442d0d8
commit
14715e3a64
4 changed files with 29 additions and 2 deletions
|
|
@ -389,7 +389,7 @@ def _set_state(future, other):
|
|||
|
||||
def _call_check_cancel(destination):
|
||||
if destination.cancelled():
|
||||
if source_loop is None or source_loop is dest_loop:
|
||||
if source_loop is None or source_loop is events._get_running_loop():
|
||||
source.cancel()
|
||||
else:
|
||||
source_loop.call_soon_threadsafe(source.cancel)
|
||||
|
|
@ -398,7 +398,7 @@ def _call_set_state(source):
|
|||
if (destination.cancelled() and
|
||||
dest_loop is not None and dest_loop.is_closed()):
|
||||
return
|
||||
if dest_loop is None or dest_loop is source_loop:
|
||||
if dest_loop is None or dest_loop is events._get_running_loop():
|
||||
_set_state(destination, source)
|
||||
else:
|
||||
if dest_loop.is_closed():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue