From 6a642b0777304d16466f38aa0db2bb6325fc8314 Mon Sep 17 00:00:00 2001 From: mengw15 <125719918+mengw15@users.noreply.github.com> Date: Mon, 3 Aug 2026 13:44:14 -0700 Subject: [PATCH] fix(pyamber, test): stabilize flaky AtomicInteger get_and_set deadlock test --- amber/src/test/python/core/util/test_atomic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/amber/src/test/python/core/util/test_atomic.py b/amber/src/test/python/core/util/test_atomic.py index 824b25b6719..c8021234e02 100644 --- a/amber/src/test/python/core/util/test_atomic.py +++ b/amber/src/test/python/core/util/test_atomic.py @@ -85,8 +85,11 @@ def attempt(): # scheduling delay alone could let the assertions below pass even on # a fixed implementation. assert started.wait(timeout=2.0), "worker thread never started" - # Give get_and_set a moment to either deadlock or return. - completed.wait(timeout=0.5) + # Join instead of waiting on `completed`: the worker sets that event + # before it exits, so `is_alive()` is only reliable after a join. A + # fixed implementation joins in microseconds; a deadlocked get_and_set + # stays alive past the timeout and still trips the assertion below. + worker.join(timeout=5) assert not errors, ( f"get_and_set raised before reaching the deadlock spin: {errors[0]!r}" )