fix: ensure all spawned actors are destroyed on shutdown (closes #698)#764
Open
redddddyyyyy wants to merge 1 commit into
Open
fix: ensure all spawned actors are destroyed on shutdown (closes #698)#764redddddyyyyy wants to merge 1 commit into
redddddyyyyy wants to merge 1 commit into
Conversation
…lator#698) Wrap each actor destruction call in its own try-except block so a single failure does not abort cleanup of remaining actors. Failures are logged as warnings. Lists are copied before iteration to prevent mutation issues during teardown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #698
When pressing Ctrl+C, the ROS node exits but spawned CARLA actors (vehicles, sensors) remain alive in the simulator. The root cause is that the destroy loops in
carla_spawn_objects.pywrap all actors in a singletry-except— any one exception exits the entire loop, leaving remaining actors alive. The same pattern exists inbridge.pyandactor_factory.pywith no exception handling at all.Fix
Wrap each individual actor destruction call in its own
try-exceptblock across three files:carla_spawn_objects/src/carla_spawn_objects/carla_spawn_objects.py: per-actor try-except indestroy()carla_ros_bridge/src/carla_ros_bridge/bridge.py: per-actor try-except indestroy()carla_ros_bridge/src/carla_ros_bridge/actor_factory.py: per-actor try-except inclear()Failed destructions are logged as warnings but do not abort cleanup of remaining actors. Lists are copied before iteration to prevent mutation issues during teardown.
Testing
The fix has been verified by code review. The change is mechanical — moving exception handling from wrapping entire loops to wrapping individual iterations — and the logic is straightforward to confirm by reading.
This change is