From 7ec02f9bb05518652009ecdf99f793fcf2524bd6 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 21 Mar 2018 09:22:29 +0545 Subject: [PATCH] issue #156: ensure Latch state is cleaned up if select throws. --- mitogen/core.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mitogen/core.py b/mitogen/core.py index 39ef818a..c0f14993 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -953,7 +953,11 @@ class Latch(object): self._lock.release() _vv and IOLOG.debug('%r.get() -> sleeping', self) - restart(select.select, [_tls.rsock], [], [], timeout) + e = None + try: + restart(select.select, [_tls.rsock], [], [], timeout) + except Exception, e: + pass self._lock.acquire() try: @@ -964,6 +968,8 @@ class Latch(object): raise TimeoutError() if _tls.rsock.recv(2) != '\x7f': raise LatchError('internal error: received >1 wakeups') + if e: + raise e if self.closed: raise LatchError() _vv and IOLOG.debug('%r.get() wake -> %r', self, self._queue[i])