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

Exit with code 0 if ExternalShutdownException is raised #581

Merged
merged 4 commits into from
Aug 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

from example_interfaces.srv import AddTwoInts

import rclpy
Expand Down Expand Up @@ -41,10 +39,8 @@ def main(args=None):

try:
rclpy.spin(node)
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
# Destroy the node explicitly
# (optional - Done automatically when node is garbage collected)
Expand Down
6 changes: 1 addition & 5 deletions demo_nodes_py/demo_nodes_py/topics/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.node import Node
Expand All @@ -37,10 +35,8 @@ def main(args=None):
node = Listener()
try:
rclpy.spin(node)
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
node.destroy_node()
rclpy.try_shutdown()
Expand Down
4 changes: 1 addition & 3 deletions demo_nodes_py/demo_nodes_py/topics/listener_qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ def main(argv=sys.argv[1:]):
while rclpy.ok() and cycle_count < args.number_of_cycles:
rclpy.spin_once(node)
cycle_count += 1
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
node.destroy_node()
rclpy.try_shutdown()
Expand Down
6 changes: 1 addition & 5 deletions demo_nodes_py/demo_nodes_py/topics/listener_serialized.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.node import Node
Expand Down Expand Up @@ -43,10 +41,8 @@ def main(args=None):

try:
rclpy.spin(serialized_subscriber)
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
Expand Down
6 changes: 1 addition & 5 deletions demo_nodes_py/demo_nodes_py/topics/talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.node import Node
Expand Down Expand Up @@ -45,10 +43,8 @@ def main(args=None):

try:
rclpy.spin(node)
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
node.destroy_node()
rclpy.try_shutdown()
Expand Down
4 changes: 1 addition & 3 deletions demo_nodes_py/demo_nodes_py/topics/talker_qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ def main(argv=sys.argv[1:]):
while rclpy.ok() and cycle_count < args.number_of_cycles:
rclpy.spin_once(node)
cycle_count += 1
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
node.destroy_node()
rclpy.try_shutdown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import sys

from quality_of_service_demo_py.common_nodes import Listener
from quality_of_service_demo_py.common_nodes import Talker
Expand Down Expand Up @@ -72,10 +71,8 @@ def main(args=None):
executor.add_node(talker)
try:
executor.spin()
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
rclpy.try_shutdown()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ def main(args=None):
try:
while talker.publish_count < num_msgs:
executor.spin_once()
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
return 1
finally:
rclpy.try_shutdown()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.executors import SingleThreadedExecutor
Expand Down Expand Up @@ -69,10 +67,8 @@ def main():

try:
executor.spin()
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
rclpy.try_shutdown()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.node import Node
Expand Down Expand Up @@ -53,10 +51,8 @@ def main(args=None):
node = Listener()
try:
rclpy.spin(node)
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
rclpy.try_shutdown()
node.destroy_node()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import rclpy
from rclpy.executors import ExternalShutdownException
from rclpy.node import Node
Expand Down Expand Up @@ -61,10 +59,8 @@ def main(args=None):

try:
rclpy.spin(node)
except KeyboardInterrupt:
except (KeyboardInterrupt, ExternalShutdownException):
pass
except ExternalShutdownException:
sys.exit(1)
finally:
rclpy.try_shutdown()
node.destroy_node()
Expand Down