decrease connection timeout

This commit is contained in:
Kay Kurokawa 2017-03-24 13:02:01 -04:00 committed by Alex Grintsvayg
parent 3af5e9dc5c
commit ddd8fd1a77

View file

@ -21,6 +21,7 @@ class PeerConnectionHandler(object):
class ConnectionManager(object): class ConnectionManager(object):
implements(interfaces.IConnectionManager) implements(interfaces.IConnectionManager)
MANAGE_CALL_INTERVAL_SEC = 5 MANAGE_CALL_INTERVAL_SEC = 5
TCP_CONNECT_TIMEOUT = 15
def __init__(self, downloader, rate_limiter, def __init__(self, downloader, rate_limiter,
primary_request_creators, secondary_request_creators): primary_request_creators, secondary_request_creators):
@ -208,7 +209,8 @@ class ConnectionManager(object):
lambda c_was_made: self._peer_disconnected(c_was_made, peer)) lambda c_was_made: self._peer_disconnected(c_was_made, peer))
self._peer_connections[peer] = PeerConnectionHandler(self._primary_request_creators[:], self._peer_connections[peer] = PeerConnectionHandler(self._primary_request_creators[:],
factory) factory)
connection = reactor.connectTCP(peer.host, peer.port, factory) connection = reactor.connectTCP(peer.host, peer.port, factory,
timeout=self.TCP_CONNECT_TIMEOUT)
self._peer_connections[peer].connection = connection self._peer_connections[peer].connection = connection
def _peer_disconnected(self, connection_was_made, peer): def _peer_disconnected(self, connection_was_made, peer):