Commit 2c22c418 authored by David Wilson's avatar David Wilson

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

parent 07a8994f
...@@ -925,9 +925,9 @@ item. ...@@ -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): ...@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment