Skip to content

The agent that grows with you

test(gateway): the queued lease release check is event-coordinated, not a 0.5 s bound

Teknium83463db3daa7
diff --git a/tests/gateway/test_active_lease_release_off_loop.py b/tests/gateway/test_active_lease_release_off_loop.py
index 3dd8644be57..fde9e4777f8 100644
--- a/tests/gateway/test_active_lease_release_off_loop.py
+++ b/tests/gateway/test_active_lease_release_off_loop.py
@@ -20,10 +20,12 @@ def test_a_queued_release_returns_while_the_registry_is_locked_and_lands_after(t
held = active_sessions._FileLock(lease.lock_path) # another process mid-rewrite
held.__enter__()
try:
- started = time.monotonic()
- release_soon(lease)
- assert time.monotonic() - started < 0.5, "the release waited on the registry lock in the caller"
- assert threading.current_thread() is threading.main_thread()
+ caller = threading.Thread(target=release_soon, args=(lease,), daemon=True)
+ caller.start()
+ caller.join(timeout=5)
+ # The registry lock is still held, so a caller that returned did not release inline.
+ assert not caller.is_alive(), "the release waited on the registry lock in the caller"
+ assert not lease.released
finally:
held.__exit__(None, None, None)
deadline = time.monotonic() + 5