Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid race in emitting event by using loop.call_soon_threadsafe() #119

Merged
merged 1 commit into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion launch_ros/examples/lifecycle_pub_sub_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def main(argv=sys.argv[1:]):
print('Starting launch of launch description...')
print('')

# ls = LaunchService(argv=argv, debug=True)
# ls = launch.LaunchService(argv=argv, debug=True)
ls = launch.LaunchService(argv=argv)
ls.include_launch_description(get_default_launch_description(prefix_output_with_name=False))
ls.include_launch_description(ld)
Expand Down
5 changes: 3 additions & 2 deletions launch_ros/launch_ros/actions/lifecycle_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ def _on_transition_event(self, context, msg):
try:
event = StateTransition(action=self, msg=msg)
self.__current_state = ChangeState.valid_states[msg.goal_state.id]
context.emit_event_sync(event)
context.asyncio_loop.call_soon_threadsafe(lambda: context.emit_event_sync(event))
except Exception as exc:
print("Exception in handling of 'lifecycle.msg.TransitionEvent': {}".format(exc))
_logger.error(
"Exception in handling of 'lifecycle.msg.TransitionEvent': {}".format(exc))

def _call_change_state(self, request, context: launch.LaunchContext):
while not self.__rclpy_change_state_client.wait_for_service(timeout_sec=1.0):
Expand Down