for contender in ("reader", "writer"):
thread, event = contender_bits[contender]
with self.condition:
while not self.active_thread:
self.condition.wait()
> assert self.active_thread == contender
E AssertionError: assert 'writer' == 'reader'
E - reader
E + writer
kazoo/tests/test_lock.py:515: AssertionError
Why is this needed?
test_rw_lock is creating 2 threads (reader and writer) and, after being started, it is expected that reader is a contender before writer. In some busy systems (like the CI... it's always the CI!) this may not be true and lead to the test failure because writer can be a contender before reader. This commit makes sure that reader is always a contender before writer.
Proposed Changes
wait for reader being a contender before starting writer
rewrote some minimal part of the test, just because I was there
See test failure https://github.com/python-zk/kazoo/actions/runs/8116444130/job/22206401448?pr=744
Why is this needed?
test_rw_lock
is creating 2 threads (reader
andwriter
) and, after being started, it is expected thatreader
is a contender beforewriter
. In some busy systems (like the CI... it's always the CI!) this may not be true and lead to the test failure becausewriter
can be a contender beforereader
. This commit makes sure thatreader
is always a contender beforewriter
.Proposed Changes
reader
being a contender before startingwriter
Does this PR introduce any breaking change?
No!