Skip to content

Commit e471388

Browse files
cyan-atbjsowa
authored andcommitted
fix: rosbridge_websocket cooperative shutdown (backport #1048)
* rosbridge_websocket cooperative shutdown necessary changes * switch back to singlethread, check for ok BEFORE spinning also * address MatthijsBurgh comments
1 parent cad53d7 commit e471388

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
@@ -369,9 +369,10 @@ def main(args=None):
369369
executor.add_node(node)
370370

371371
def spin_ros():
372-
executor.spin_once(timeout_sec=0.01)
373372
if not rclpy.ok():
374373
shutdown_hook()
374+
return
375+
executor.spin_once(timeout_sec=0.01)
375376

376377
spin_callback = PeriodicCallback(spin_ros, 1)
377378
spin_callback.start()
@@ -382,6 +383,7 @@ def spin_ros():
382383
except KeyboardInterrupt:
383384
print("Exiting due to SIGINT")
384385
finally:
386+
spin_callback.stop()
385387
shutdown_hook() # shutdown hook to stop the server
386388

387389

0 commit comments

Comments
 (0)