Skip to content

Commit

Permalink
Initialize signal handlers after context (#1331)
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <[email protected]>
  • Loading branch information
sloretz authored Aug 7, 2024
1 parent ee79763 commit aacf8f0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rclpy/rclpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ def __init__(self,
self.installed_signal_handlers = False
else:
self.installed_signal_handlers = True
install_signal_handlers(signal_handler_options)
self.context.init(args, domain_id=domain_id)
# Install signal handlers after initializing the context because the rclpy signal
# handler only does something if there is at least one initialized context.
# It is desirable for sigint or sigterm to be able to terminate the process if rcl_init
# takes a long time, and the default signal handlers work well for that purpose.
install_signal_handlers(signal_handler_options)

def __enter__(self) -> 'InitContextManager':
return self
Expand Down

0 comments on commit aacf8f0

Please sign in to comment.