Skip to content

Commit

Permalink
Destroy nodes after node creation tests.
Browse files Browse the repository at this point in the history
The test teardown method is calling rclpy.shutdown() before the nodes
created here are destroyed. With the inclusion of parameter services
this is causing the tests to hang after printing the following
exceptions:

    ========================================================================================================================== 7 passed in 0.11 seconds
    Exception ignored in: <bound method Node.__del__ of <rclpy.node.Node object at 0x7fc321e0fd30>>
    Traceback (most recent call last):
      File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 410, in __del__
        self.destroy_node()
      File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 353, in destroy_node
        _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle)
    RuntimeError: Failed to fini 'rcl_service_t': rcl node is invalid, rcl instance id does not match, at /tmp/scree/src/ros2/rcl/rcl/src/rcl/node.c:461
    Exception ignored in: <bound method Node.__del__ of <rclpy.node.Node object at 0x7fc320597828>>
    Traceback (most recent call last):
      File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 410, in __del__
        self.destroy_node()
      File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 353, in destroy_node
        _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle)
    RuntimeError: Failed to fini 'rcl_service_t': rcl node is invalid, rcl instance id does not match, at /tmp/scree/src/ros2/rcl/rcl/src/rcl/node.c:461
    Exception ignored in: <bound method Node.__del__ of <rclpy.node.Node object at 0x7fc320597b70>>
    Traceback (most recent call last):
      File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 410, in __del__
        self.destroy_node()
      File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 353, in destroy_node
        _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle)
    RuntimeError: Failed to fini 'rcl_service_t': rcl node is invalid, rcl instance id does not match, at /tmp/scree/src/ros2/rcl/rcl/src/rcl/node.c:461

Destroying the nodes before the teardown runs resolves both the
indefinite hang and the exceptions.
  • Loading branch information
nuclearsandwich committed Aug 16, 2018
1 parent a8231e0 commit e6c7125
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rclpy/test/test_create_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,26 @@ def tearDownClass(cls):

def test_create_node(self):
node_name = 'create_node_test'
rclpy.create_node(node_name)
rclpy.create_node(node_name).destroy_node()

def test_create_node_with_namespace(self):
node_name = 'create_node_test'
namespace = '/ns'
rclpy.create_node(node_name, namespace=namespace)
rclpy.create_node(node_name, namespace=namespace).destroy_node()

def test_create_node_with_empty_namespace(self):
node_name = 'create_node_test'
namespace = ''
node = rclpy.create_node(node_name, namespace=namespace)
self.assertEqual('/', node.get_namespace())
node.destroy_node()

def test_create_node_with_relative_namespace(self):
node_name = 'create_node_test'
namespace = 'ns'
node = rclpy.create_node(node_name, namespace=namespace)
self.assertEqual('/ns', node.get_namespace())
node.destroy_node()

def test_create_node_invalid_name(self):
node_name = 'create_node_test_invalid_name?'
Expand Down

0 comments on commit e6c7125

Please sign in to comment.