From 777d5a71d20c575ab6e16a43df092556c938ca46 Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Fri, 2 Dec 2016 18:13:42 +0200 Subject: [PATCH] Handle select error (EINTR) properly --- pupy/network/lib/streams/PupySocketStream.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pupy/network/lib/streams/PupySocketStream.py b/pupy/network/lib/streams/PupySocketStream.py index b77a4bef..6cfe76d1 100644 --- a/pupy/network/lib/streams/PupySocketStream.py +++ b/pupy/network/lib/streams/PupySocketStream.py @@ -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')