fix: notify_all on lock timeout to wake blocked readers

When acquire_write or acquire_read times out, call notify_all() before
returning False so waiters blocked by the timed-out thread's presence
(e.g. readers blocked by writer-preference _writers_waiting > 0) are
woken immediately instead of sleeping until the next external notify.
This commit is contained in:
kshitij
2026-08-07 13:46:29 +05:30
committed by kshitij
parent a1e5ccb325
commit 65de109ef3
+2
View File
@@ -504,6 +504,7 @@ class _ReadWriteLock:
if deadline is not None:
remaining = deadline - time.monotonic()
if remaining <= 0:
self._cond.notify_all()
return False
self._cond.wait(timeout=remaining)
else:
@@ -533,6 +534,7 @@ class _ReadWriteLock:
if deadline is not None:
remaining = deadline - time.monotonic()
if remaining <= 0:
self._cond.notify_all()
return False
self._cond.wait(timeout=remaining)
else: