Skip to content

Commit

Permalink
Join threads to avoid sleeping
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <sloretz@openrobotics.org>
  • Loading branch information
sloretz committed Dec 15, 2021
1 parent e6fe67a commit a8ddedf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rclpy/test/test_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def run():
nonlocal retval
retval = clock.sleep_until(clock.now() + Duration(seconds=10))

t = threading.Thread(target=run, daemon=True)
t = threading.Thread(target=run)
t.start()

# wait for thread to get inside sleep_until call
Expand All @@ -291,7 +291,7 @@ def run():
clock._set_ros_time_is_active(ros_time_enabled)

# wait for thread to exit
time.sleep(0.2)
t.join()

assert retval is False

Expand All @@ -305,7 +305,7 @@ def run():
retval = clock.sleep_until(
clock.now() + Duration(seconds=10), context=non_default_context)

t = threading.Thread(target=run, daemon=True)
t = threading.Thread(target=run)
t.start()

# wait for thread to get inside sleep_until call
Expand All @@ -314,7 +314,7 @@ def run():
non_default_context.shutdown()

# wait for thread to exit
time.sleep(0.2)
t.join()

assert retval is False

Expand All @@ -333,7 +333,7 @@ def run():
nonlocal retval
retval = clock.sleep_until(stop_time)

t = threading.Thread(target=run, daemon=True)
t = threading.Thread(target=run)
t.start()

# wait for thread to get inside sleep_until call
Expand All @@ -342,7 +342,7 @@ def run():
clock.set_ros_time_override(stop_time)

# wait for thread to exit
time.sleep(0.2)
t.join()

assert retval

Expand Down

0 comments on commit a8ddedf

Please sign in to comment.