@@ -452,7 +452,7 @@ def timer_callback() -> None:
452452                timer  =  self .node .create_timer (0.003 , timer_callback )
453453
454454                # Timeout 
455-                 future  =  Future ()
455+                 future  =  executor . create_future ()
456456                self .assertFalse (future .done ())
457457                start  =  time .perf_counter ()
458458                executor .spin_until_future_complete (future = future , timeout_sec = 0.1 )
@@ -479,7 +479,7 @@ def set_future_result(future):
479479                    future .set_result ('finished' )
480480
481481                # Future complete timeout_sec > 0 
482-                 future  =  Future ()
482+                 future  =  executor . create_future ()
483483                self .assertFalse (future .done ())
484484                t  =  threading .Thread (target = lambda : set_future_result (future ))
485485                t .start ()
@@ -488,7 +488,7 @@ def set_future_result(future):
488488                self .assertEqual (future .result (), 'finished' )
489489
490490                # Future complete timeout_sec = None 
491-                 future  =  Future ()
491+                 future  =  executor . create_future ()
492492                self .assertFalse (future .done ())
493493                t  =  threading .Thread (target = lambda : set_future_result (future ))
494494                t .start ()
@@ -497,7 +497,7 @@ def set_future_result(future):
497497                self .assertEqual (future .result (), 'finished' )
498498
499499                # Future complete timeout < 0 
500-                 future  =  Future ()
500+                 future  =  executor . create_future ()
501501                self .assertFalse (future .done ())
502502                t  =  threading .Thread (target = lambda : set_future_result (future ))
503503                t .start ()
@@ -519,7 +519,7 @@ def timer_callback() -> None:
519519                timer  =  self .node .create_timer (0.003 , timer_callback )
520520
521521                # Do not wait timeout_sec = 0 
522-                 future  =  Future ()
522+                 future  =  executor . create_future ()
523523                self .assertFalse (future .done ())
524524                executor .spin_until_future_complete (future = future , timeout_sec = 0 )
525525                self .assertFalse (future .done ())
@@ -602,7 +602,7 @@ def test_single_threaded_spin_once_until_future(self):
602602            with  self .subTest (cls = cls ):
603603                executor  =  cls (context = self .context )
604604
605-                 future  =  Future ( executor = executor )
605+                 future  =  executor . create_future ( )
606606
607607                # Setup a thread to spin_once_until_future_complete, which will spin 
608608                # for a maximum of 10 seconds. 
@@ -630,7 +630,7 @@ def test_multi_threaded_spin_once_until_future(self):
630630        self .assertIsNotNone (self .node .handle )
631631        executor  =  MultiThreadedExecutor (context = self .context )
632632
633-         future   =   Future ( executor = executor )
633+         future :  Future [ bool ]  =   executor . create_future ( )
634634
635635        # Setup a thread to spin_once_until_future_complete, which will spin 
636636        # for a maximum of 10 seconds. 
@@ -679,7 +679,7 @@ def timer2_callback() -> None:
679679                timer2  =  self .node .create_timer (1.5 , timer2_callback , callback_group )
680680
681681                executor .add_node (self .node )
682-                 future  =  Future ( executor = executor )
682+                 future  =  executor . create_future ( )
683683                executor .spin_until_future_complete (future , 4 )
684684
685685                assert  count  ==  2 
@@ -689,6 +689,17 @@ def timer2_callback() -> None:
689689                self .node .destroy_timer (timer1 )
690690                self .node .destroy_client (cli )
691691
692+     def  test_create_future_returns_future_with_executor_attached (self ) ->  None :
693+         self .assertIsNotNone (self .node .handle )
694+         for  cls  in  [SingleThreadedExecutor , MultiThreadedExecutor , EventsExecutor ]:
695+             with  self .subTest (cls = cls ):
696+                 executor  =  cls (context = self .context )
697+                 try :
698+                     fut  =  executor .create_future ()
699+                     self .assertEqual (executor , fut ._executor ())
700+                 finally :
701+                     executor .shutdown ()
702+ 
692703
693704if  __name__  ==  '__main__' :
694705    unittest .main ()
0 commit comments