diff --git a/launch/launch/launch_service.py b/launch/launch/launch_service.py index 54677dd96..28e312588 100644 --- a/launch/launch/launch_service.py +++ b/launch/launch/launch_service.py @@ -127,6 +127,7 @@ def emit_event(self, event: Event) -> None: If the LaunchService is not running, the event is queued until it is. """ + future = None with self.__loop_from_run_thread_lock: if self.__loop_from_run_thread is not None: # loop is in use, asynchronously emit the event @@ -134,11 +135,14 @@ def emit_event(self, event: Event) -> None: self.__context.emit_event(event), self.__loop_from_run_thread ) - future.result() else: # loop is not in use, synchronously emit the event, and it will be processed later self.__context.emit_event_sync(event) + if future is not None: + # Block until asynchronously emitted event is emitted by loop + future.result() + def include_launch_description(self, launch_description: LaunchDescription) -> None: """ Evaluate a given LaunchDescription and visits all of its entities.