core: make try/catch logic a little clearer in Latch.get()

pull/255/head
David Wilson 7 years ago
parent 05a5f2b6e5
commit 55fff54774

@ -1131,21 +1131,21 @@ class Latch(object):
finally: finally:
self._lock.release() self._lock.release()
return self._get_sleep(timeout, block, rsock, wsock) poller = self.poller_class()
poller.start_receive(rsock.fileno())
try:
return self._get_sleep(poller, timeout, block, rsock, wsock)
finally:
poller.close()
def _get_sleep(self, timeout, block, rsock, wsock): def _get_sleep(self, poller, timeout, block, rsock, wsock):
_vv and IOLOG.debug('%r._get_sleep(timeout=%r, block=%r)', _vv and IOLOG.debug('%r._get_sleep(timeout=%r, block=%r)',
self, timeout, block) self, timeout, block)
e = None e = None
poller = self.poller_class()
poller.start_receive(rsock.fileno())
try:
try: try:
list(poller.poll(timeout)) list(poller.poll(timeout))
except Exception: except Exception:
e = sys.exc_info()[1] e = sys.exc_info()[1]
finally:
poller.close()
self._lock.acquire() self._lock.acquire()
try: try:

Loading…
Cancel
Save