Antoine Pitrou added the comment:

Actually, wait() calls self._waiters.remove() without holding the lock. But I 
think it could easily do so after taking the lock (since it takes it anyway 
before returning).

Also, _waiters should better be a set, since wait() needs the associative 
behaviour when unregistering a waiter.

notify() would then look like:

for i in range(n):
    try:
        waiter = self._waiters.pop()
    except KeyError:
        break
    waiter.release()

and wait() would look like:

waiter = _allocate_lock()
waiter.acquire()
self._waiters.add(waiter)
self._release_save()
try:
    return waiter.acquire(timeout)
finally:
    self._acquire_restore()
    self._waiters.discard(waiter)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17385>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to