mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Make add and remove methods of connection manager private (#1372)
This commit is contained in:
parent
1272c2c37e
commit
92864f6f15
2 changed files with 7 additions and 8 deletions
|
|
@ -77,7 +77,7 @@ class ConnectionManager(object):
|
|||
logger.debug("Doing handshake.")
|
||||
connection.handshake()
|
||||
logger.debug("Adding peer.")
|
||||
self.add_peer(peer)
|
||||
self._add_peer(peer)
|
||||
result_queue.put(
|
||||
ConnectPeerResult.from_success(peer.remote_address))
|
||||
logger.debug("Yielding connection.")
|
||||
|
|
@ -87,7 +87,7 @@ class ConnectionManager(object):
|
|||
raise
|
||||
finally:
|
||||
logger.debug("Removing peer.")
|
||||
self.remove_peer(peer)
|
||||
self._remove_peer(peer)
|
||||
peer.stop()
|
||||
|
||||
@property
|
||||
|
|
@ -114,7 +114,7 @@ class ConnectionManager(object):
|
|||
return True
|
||||
return False
|
||||
|
||||
def add_peer(self, peer: Peer):
|
||||
def _add_peer(self, peer: Peer):
|
||||
"""Add a peer.
|
||||
"""
|
||||
with self.peers_lock:
|
||||
|
|
@ -130,8 +130,8 @@ class ConnectionManager(object):
|
|||
logger.debug('Added peer {}'.format(peer))
|
||||
self.on_peers_changed()
|
||||
|
||||
def remove_peer(self, peer: Peer):
|
||||
"""Add a peer.
|
||||
def _remove_peer(self, peer: Peer):
|
||||
"""Remove a peer.
|
||||
"""
|
||||
with self.peers_lock:
|
||||
if not self.has_connection(peer.remote_address):
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class PeerClient(object):
|
|||
|
||||
# Wait for connect result from the queue.
|
||||
connect_result = result_queue.get()
|
||||
logger.info("connect_result: {}".format(connect_result))
|
||||
logger.debug("connect_result: {}".format(connect_result))
|
||||
if connect_result.failure is not None:
|
||||
raise connect_result.failure
|
||||
|
||||
|
|
@ -62,7 +62,6 @@ class PeerClient(object):
|
|||
logger.info('Conecting to address: {}'.format(address))
|
||||
try:
|
||||
peer_socket = self.get_socket()
|
||||
logger.info('Trying to connect socket to {}'.format(address))
|
||||
peer_socket.settimeout(SOCKET_CONNECT_TIMEOUT)
|
||||
peer_socket.connect(address)
|
||||
peer_socket.setblocking(True)
|
||||
|
|
@ -72,7 +71,7 @@ class PeerClient(object):
|
|||
result_queue,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception('Failed to make connection to {}'.format(address))
|
||||
logger.exception('Failed to connect to {}'.format(address))
|
||||
result_queue.put(ConnectPeerResult.from_failure(e))
|
||||
|
||||
def handle_connection(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue