mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-15 12:50:47 +02:00
Catch exception and shutdown peer in handshake fail (#1269)
* Catch exception and shutdown peer in handshake fail * Don't raise exception on remove peer when doesn't exist
This commit is contained in:
parent
11ce7c275f
commit
c2a3ea3ca4
2 changed files with 5 additions and 6 deletions
|
|
@ -45,11 +45,11 @@ class Connection(object):
|
|||
|
||||
@contextmanager
|
||||
def connect(self, connection_manager):
|
||||
self.start_receiving_msgs()
|
||||
self.handshake()
|
||||
logger.debug("Adding peer.")
|
||||
connection_manager.add_peer(self.peer)
|
||||
try:
|
||||
self.start_receiving_msgs()
|
||||
self.handshake()
|
||||
logger.debug("Adding peer.")
|
||||
connection_manager.add_peer(self.peer)
|
||||
logger.debug("Yielding peer.")
|
||||
yield self
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ class ConnectionManager(object):
|
|||
"""
|
||||
with self.peers_lock:
|
||||
if not self.has_connection(peer.remote_address):
|
||||
logger.debug('Failed to remove peer {}'.format(peer))
|
||||
raise MissingPeerError()
|
||||
return
|
||||
del self._peers[peer.remote_address]
|
||||
logger.debug('Removed peer {}'.format(peer))
|
||||
self.on_peers_changed()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue