From bf302a08389c3ecb61b8867dbbc120cd251f598a Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 May 2019 18:03:16 +0200 Subject: [PATCH] tests: hopefully fix sporadic test failures with condition var test --- tests/pipeline/test_condition_var.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/pipeline/test_condition_var.py b/tests/pipeline/test_condition_var.py index 3458d1c9b6..38c7c4cf25 100644 --- a/tests/pipeline/test_condition_var.py +++ b/tests/pipeline/test_condition_var.py @@ -72,16 +72,22 @@ def test_cvar_notify_thread(num_threads): break assert state['waiting'] == num_threads - m.release() # OK, now signal it, and yield. One thread must be unblocked per notify. for i in range(num_threads): cv.notify() - yield_thread() - m.acquire() - assert state['waiting'] == num_threads - i - 1 - m.release() + expected_waiters = num_threads - i - 1 + for j in range(1000): + m.release() + yield_thread() + m.acquire() + if state['waiting'] == expected_waiters: + break + + assert state['waiting'] == expected_waiters + + m.release() for thread in threads: thread.join() cv = None