File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""Tests for tasks.py."""
22
33import collections
4+ from concurrent .futures import thread
45import contextlib
56import contextvars
67import gc
@@ -3680,6 +3681,18 @@ def task_factory(loop, coro):
36803681 (loop , context ), kwargs = callback .call_args
36813682 self .assertEqual (context ['exception' ], exc_context .exception )
36823683
3684+ def test_run_coroutine_threadsafe_and_cancel (self ):
3685+ async def target ():
3686+ # self.loop.run_in_executor(None, _in_another_thread)
3687+ thread_future = asyncio .run_coroutine_threadsafe (self .add (1 , 2 ), self .loop )
3688+ await asyncio .sleep (0 )
3689+
3690+ thread_future .cancel ()
3691+ await asyncio .sleep (0 )
3692+
3693+ self .loop .run_until_complete (target ())
3694+ self .assertEqual (0 , len (self .loop ._ready ))
3695+
36833696
36843697class SleepTests (test_utils .TestCase ):
36853698 def setUp (self ):
You can’t perform that action at this time.
0 commit comments