diff --git a/sjrpc/core/rpcconnection.py b/sjrpc/core/rpcconnection.py index 02e6c3a1860125d67461444d5fd6c3338b169b2e..0c6a6a1498aa90bb1e8bbae12a01b30d52645180 100644 --- a/sjrpc/core/rpcconnection.py +++ b/sjrpc/core/rpcconnection.py @@ -112,11 +112,20 @@ class RpcConnection(object): Receive data from socket into the inbound buffer. If data can be decoded, do it and pass result to :meth:`dispatch` method. ''' - - buf = self._sock.recv(RpcConnection.RECV_BUF_SIZE) + + try: + buf = self._sock.recv(RpcConnection.RECV_BUF_SIZE) + except socket.error as err: + if err.errno == 11: + # Errno 11 -> retry again + logging.warning('Non critical error while reading a socket:' + ' %r', err) + return + if not buf: + # Empty buffer = closed socket. raise socket.error() - + self._inbound_buffer.push(buf) # Read the message length: if self._cur_msg_size is None and len(self._inbound_buffer) >= 4: