Calling waiters.wait_for_any() blocks if future has called Condition.wait()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
futurist |
Opinion
|
Medium
|
Herve Beraud |
Bug Description
For additional reference see: https:/
I created my own reentrant read write lock which uses Condtion.wait() to wait on pending locks.
This lock is shared with two tasks that are submitted to a GreenThreadPool
Since one of the tasks tries to acquire the read lock and the other the write lock one of the two will block on the Condition.wait().
When waiters.
I believe this behavior to be incorrect as one of the futures has successfully finished and as a result should be returned by wait_for_any.
I use the rest of the information to describe the classes, methods and calls that lead to this behavior. Starting with large parts of the ReentrantReadWr
class ReentrantReadWr
def __init__(self):
def read_acquire(self, blocking=True, timeout=-1):
waitout = None if timeout == -1 else timeout
first_it = True
try:
if self._read_
return False
finally:
def write_acquire(self, blocking=True, timeout=-1):
waitout = None if timeout == -1 else timeout
first_it = True
try:
if self._write_
return False
finally:
This is my test case, this test will block on results = waiters.
specifying the timeout parameter does not resolve the issue:
def get_read(self, rrwlock):
return rrwlock.
def get_write(self, rrwlock):
return rrwlock.
def test():
self.
rrwlock = ReentrantReadWr
futures = []
futures.
futures.
# Get the results and verify only one of the calls succeeded
# assert that the other call is still pending
results = waiters.
self.
self.
Changed in futurist: | |
importance: | Undecided → Medium |
This bug seems very related even though closed: https:/ /bugs.python. org/issue20319
It describes how concurrent. futures. wait() can block forever even if futures have finished. Its closed but based on the discussion I wouldn't actually call it resolved.
I have tracked that the blocking on the main thread occurs on waiter. event.wait( timeout) line 208 in file waiters.py