Commit 43ba1c76 authored by David Wilson's avatar David Wilson

core: wrap selects in EINTR handlers

This isn't nearly enough, but it catches the most common victim of
EINTR.
parent aafe458a
...@@ -158,6 +158,15 @@ def takes_router(func): ...@@ -158,6 +158,15 @@ def takes_router(func):
return func return func
def restart(func, *args):
while True:
try:
return func(*args)
except (select.error, OSError), e:
if e[0] != errno.EINTR:
raise
def set_cloexec(fd): def set_cloexec(fd):
flags = fcntl.fcntl(fd, fcntl.F_GETFD) flags = fcntl.fcntl(fd, fcntl.F_GETFD)
fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC) fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC)
...@@ -815,7 +824,7 @@ class Latch(object): ...@@ -815,7 +824,7 @@ class Latch(object):
finally: finally:
self.lock.release() self.lock.release()
rfds, _, _ = select.select([_tls.rsock], [], [], timeout) rfds, _, _ = restart(select.select, [_tls.rsock], [], [], timeout)
assert len(rfds) or timeout is not None assert len(rfds) or timeout is not None
self.lock.acquire() self.lock.acquire()
...@@ -1142,8 +1151,12 @@ class Broker(object): ...@@ -1142,8 +1151,12 @@ class Broker(object):
#IOLOG.debug('readers = %r', self._readers) #IOLOG.debug('readers = %r', self._readers)
#IOLOG.debug('writers = %r', self._writers) #IOLOG.debug('writers = %r', self._writers)
rsides, wsides, _ = select.select(self._readers, self._writers, rsides, wsides, _ = restart(select.select,
(), timeout) self._readers,
self._writers,
(), timeout
)
for side in rsides: for side in rsides:
_vv and IOLOG.debug('%r: POLLIN for %r', self, side) _vv and IOLOG.debug('%r: POLLIN for %r', self, side)
self._call(side.stream, side.stream.on_receive) self._call(side.stream, side.stream.on_receive)
......
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