issue #156: don't decrement `waking` if we timed out rather than being woken.

pull/167/head
David Wilson 7 years ago
parent 07a8994ff5
commit 2c22c41819

@ -925,9 +925,9 @@ item.
:py:meth:`mitogen.core.Latch.put`. :py:meth:`mitogen.core.Latch.put`.
**4. Wake, Non-empty** **4. Wake, Non-empty**
On wake it re-acquires `lock`, removes itself from `sleeping`, decrementing On wake it re-acquires `lock`, removes itself from `sleeping`, throws
`waking`, throws :py:class:`mitogen.core.TimeoutError` if no byte was :py:class:`mitogen.core.TimeoutError` if no byte was written, decrements
written, otherwise pops and returns the first item in `queue` that is `waking`, then pops and returns the first item in `queue` that is
guaranteed to exist. guaranteed to exist.

@ -957,11 +957,11 @@ class Latch(object):
self._lock.acquire() self._lock.acquire()
try: try:
self._sleeping.remove(_tls.wsock) self._sleeping.remove(_tls.wsock)
self._waking -= 1
if self.closed: if self.closed:
raise LatchError() raise LatchError()
if not rfds: if not rfds:
raise TimeoutError() raise TimeoutError()
self._waking -= 1
if _tls.rsock.recv(2) != '\x7f': if _tls.rsock.recv(2) != '\x7f':
raise LatchError('internal error: received >1 wakeups') raise LatchError('internal error: received >1 wakeups')
try: try:

Loading…
Cancel
Save