From f41b6ab72159257d187f6c5b9225b5c8420f2928 Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Mon, 31 Jan 2011 17:24:32 +0100 Subject: [PATCH] Better disconnection handling. --- sjrpc/core/connectionmanagers.py | 6 ++++-- sjrpc/core/rpcconnection.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sjrpc/core/connectionmanagers.py b/sjrpc/core/connectionmanagers.py index 2aeef7c..ade66a7 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 702ccdf..02e6c3a 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): ''' -- GitLab