Commit 22da0af4 authored by Antoine Millet's avatar Antoine Millet
Browse files

Addded an option (default disabled) to enable tcp keepalive

parent ce0aad43
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ class RpcConnection(object):
                  'write': select.POLLOUT, 'hup': select.POLLHUP,
                  'error': select.POLLERR | select.POLLNVAL}

    def __init__(self, sock, loop=None, *args, **kwargs):
    def __init__(self, sock, loop=None, enable_tcp_keepalive=False,
                 *args, **kwargs):
        # Sock of this connection:
        self._sock = sock
        sock.setblocking(False)
@@ -71,7 +72,8 @@ class RpcConnection(object):
            self.loop = loop

        # Activate TCP keepalive on the connection:
        #self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
        if enable_tcp_keepalive:
            self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

        # Watcher list:
        self._watchers = set()