Skip to content

Commit cb94ab9

Browse files
authored
fix: rosbridge_websocket cooperative shutdown (#1048)
* rosbridge_websocket cooperative shutdown necessary changes * switch back to singlethread, check for ok BEFORE spinning also * address MatthijsBurgh comments
1 parent c8f2a2f commit cb94ab9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rosbridge_server/scripts/rosbridge_websocket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,10 @@ def main(args=None):
343343
executor.add_node(node)
344344

345345
def spin_ros():
346-
executor.spin_once(timeout_sec=0.01)
347346
if not rclpy.ok():
348347
shutdown_hook()
348+
return
349+
executor.spin_once(timeout_sec=0.01)
349350

350351
spin_callback = PeriodicCallback(spin_ros, 1)
351352
spin_callback.start()
@@ -356,6 +357,7 @@ def spin_ros():
356357
except KeyboardInterrupt:
357358
print("Exiting due to SIGINT")
358359
finally:
360+
spin_callback.stop()
359361
shutdown_hook() # shutdown hook to stop the server
360362

361363

0 commit comments

Comments
 (0)