File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -317,6 +317,29 @@ async def coroutine():
317317 self .assertTrue (future .cancelled ())
318318 self .assertEqual (None , future .result ())
319319
320+ def test_create_task_coroutine_wake_from_another_thread (self ) -> None :
321+ self .assertIsNotNone (self .node .handle )
322+
323+ for cls in [SingleThreadedExecutor , MultiThreadedExecutor ]:
324+ with self .subTest (cls = cls ):
325+ executor = cls (context = self .context )
326+ thread_future = Future ()
327+
328+ async def coroutine ():
329+ await thread_future
330+
331+ def future_thread ():
332+ threading .Event ().wait (0.1 ) # Simulate some work
333+ thread_future .set_result (None )
334+
335+ t = threading .Thread (target = future_thread )
336+ t .start ()
337+
338+ coroutine_future = executor .create_task (coroutine )
339+ executor .spin_until_future_complete (coroutine_future , timeout_sec = 1.0 )
340+
341+ self .assertTrue (coroutine_future .done ())
342+
320343 def test_create_task_normal_function (self ) -> None :
321344 self .assertIsNotNone (self .node .handle )
322345 for cls in [SingleThreadedExecutor , EventsExecutor ]:
You can’t perform that action at this time.
0 commit comments