File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ def test_shutdown_loop() -> None:
6464 """Test shutting down an event loop."""
6565 loop = None
6666 loop_thread_ready = threading .Event ()
67+ runcoro_thread_ready = threading .Event ()
6768
6869 def _run_loop () -> None :
6970 nonlocal loop
@@ -76,10 +77,23 @@ def _run_loop() -> None:
7677 loop_thread .start ()
7778 loop_thread_ready .wait ()
7879
80+ async def _still_running ():
81+ await asyncio .sleep (5 )
82+
83+ def _run_coro () -> None :
84+ runcoro_thread_ready .set ()
85+ asyncio .run_coroutine_threadsafe (_still_running (), loop ).result (1 )
86+
87+ runcoro_thread = threading .Thread (target = _run_coro , daemon = True )
88+ runcoro_thread .start ()
89+ runcoro_thread_ready .wait ()
90+
91+ time .sleep (0.1 )
7992 aioutils .shutdown_loop (loop )
8093 for _ in range (5 ):
8194 if not loop .is_running ():
8295 break
8396 time .sleep (0.05 )
8497
8598 assert loop .is_running () is False
99+ runcoro_thread .join ()
You can’t perform that action at this time.
0 commit comments