Handle select error (EINTR) properly

This commit is contained in:
Oleksii Shevchuk 2016-12-02 18:13:42 +02:00
parent 26af5ad760
commit 777d5a71d2
1 changed files with 9 additions and 4 deletions

View File

@ -79,10 +79,15 @@ class PupySocketStream(SocketStream):
def sock_poll(self, timeout):
with self.downstream_lock:
try:
to_read, _, to_close = select([self.sock], [], [self.sock], timeout)
except socket.error:
to_close = True
to_close = None
to_read = None
while not (to_close or to_read or self.closed):
try:
to_read, _, to_close = select([self.sock], [], [self.sock], timeout)
except select_error as r:
if not r.args[0] == errno.EINTR:
to_close = True
if to_close:
raise EOFError('sock_poll error')