Skip to content

Commit

Permalink
Non-blocking wait
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed Oct 18, 2017
1 parent 0ef6a4d commit 385b18b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions rclpy/test/test_wait_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ def test_guard_condition_ready(self):
ws.add_guard_condition(gc_handle, gc_pointer)
self.assertFalse(ws.is_ready(gc_pointer))

ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(gc_pointer))

_rclpy.rclpy_trigger_guard_condition(gc_handle)
# TODO(sloretz) why does the next assertion fail with wait(0)?
ws.wait(1)
ws.wait(0)
self.assertTrue(ws.is_ready(gc_pointer))

ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(gc_pointer))
finally:
_rclpy.rclpy_destroy_entity('guard_condition', gc_handle)
Expand All @@ -61,14 +60,14 @@ def test_timer_ready(self):
ws.add_timer(timer_handle, timer_pointer)
self.assertFalse(ws.is_ready(timer_pointer))

ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(timer_pointer))

ws.wait(int(0.1 * S_TO_NS))
self.assertTrue(ws.is_ready(timer_pointer))

_rclpy.rclpy_call_timer(timer_handle)
ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(timer_pointer))
finally:
_rclpy.rclpy_destroy_entity('timer', timer_handle)
Expand All @@ -82,7 +81,7 @@ def test_subscriber_ready(self):
ws.add_subscription(sub.subscription_handle, sub.subscription_pointer)
self.assertFalse(ws.is_ready(sub.subscription_pointer))

ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(sub.subscription_pointer))

msg = String()
Expand All @@ -93,7 +92,7 @@ def test_subscriber_ready(self):
self.assertTrue(ws.is_ready(sub.subscription_pointer))

_rclpy.rclpy_take(sub.subscription_handle, sub.msg_type)
ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(sub.subscription_pointer))
finally:
self.node.destroy_publisher(pub)
Expand All @@ -111,7 +110,7 @@ def test_server_ready(self):
self.assertFalse(ws.is_ready(cli.client_pointer))
self.assertFalse(ws.is_ready(srv.service_pointer))

ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(cli.client_pointer))
self.assertFalse(ws.is_ready(srv.service_pointer))

Expand All @@ -123,7 +122,7 @@ def test_server_ready(self):
self.assertTrue(ws.is_ready(srv.service_pointer))

_rclpy.rclpy_take_request(srv.service_handle, srv.srv_type.Request)
ws.wait(1)
ws.wait(0)
self.assertFalse(ws.is_ready(srv.service_pointer))
finally:
self.node.destroy_client(cli)
Expand Down

0 comments on commit 385b18b

Please sign in to comment.