Skip to content

Commit 37d5b6a

Browse files
authored
[N/A] Fix node destruction test (#200)
Signed-off-by: Michel Hidalgo <mhidalgo@theaiinstitute.com>
1 parent 771f6ab commit 37d5b6a

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

synchros2/test/test_node.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,18 @@ def dummy_server_callback(_: Trigger.Request, response: Trigger.Response) -> Tri
5050
assert future.done() and future.result().success
5151
# Then block its sole worker thread
5252
executor.create_task(lambda: barrier.wait())
53-
executor.spin_once()
53+
while barrier.n_waiting == 0:
54+
executor.spin_once(0.1)
5455
# Then queue node destruction
5556
executor.create_task(lambda: node.destroy_node())
56-
executor.spin_once()
57-
assert not bool(node.destruction_requested) # still queued
57+
assert not node.destruction_requested # still queued
5858
# Then queue another service invocation
5959
future = client.call_async(Trigger.Request())
60-
executor.spin_once()
6160
# Unblock worker thread in executor
6261
barrier.wait()
63-
# Check that executor wraps up early due to node destruction
64-
executor.spin_until_future_complete(future, timeout_sec=5.0)
65-
assert node.destruction_requested
62+
# Check that node destruction prevents call future completion
63+
executor.spin_until_future_complete(future, timeout_sec=2.0)
64+
assert bool(node.destruction_requested)
6665
assert executor.default_thread_pool.wait(timeout=5.0)
6766
assert not future.done() # future response will never be resolved
6867
finally:

0 commit comments

Comments
 (0)