diff --git a/sjrpc/core/connectionmanagers.py b/sjrpc/core/connectionmanagers.py index 2aeef7c4091a7647257ab6737c1a93ce51d69002..ade66a72cac695da005bf3ac0a5637f11185c895 100644 --- a/sjrpc/core/connectionmanagers.py +++ b/sjrpc/core/connectionmanagers.py @@ -177,7 +177,8 @@ class ConnectionManager(object): ''' fd = connection.get_fd() - self._poll.modify(fd, ConnectionManager.MASK_WRITABLE) + if fd is not None: + self._poll.modify(fd, ConnectionManager.MASK_WRITABLE) def nothing_to_write(self, connection): ''' @@ -189,7 +190,8 @@ class ConnectionManager(object): ''' fd = connection.get_fd() - self._poll.modify(fd, ConnectionManager.MASK_NORMAL) + if fd is not None: + self._poll.modify(fd, ConnectionManager.MASK_NORMAL) def handle_event(self, fd, event): ''' diff --git a/sjrpc/core/rpcconnection.py b/sjrpc/core/rpcconnection.py index 702ccdfc3ffb402c41d93b8687703038af2538da..02e6c3a1860125d67461444d5fd6c3338b169b2e 100644 --- a/sjrpc/core/rpcconnection.py +++ b/sjrpc/core/rpcconnection.py @@ -428,8 +428,10 @@ class RpcConnection(object): :return: the file descriptor number of the socket ''' - - return self._sock.fileno() + try: + return self._sock.fileno() + except socket.error: + return None def getpeername(self): '''