From 8998bf85bd2263e62dd17d10aa0e664584b14836 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Wed, 4 Apr 2018 15:34:07 +0200 Subject: [PATCH] Handle connection errors when running peerPing command --- src/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.py b/src/main.py index a4c3730b..bc9c9282 100644 --- a/src/main.py +++ b/src/main.py @@ -461,7 +461,15 @@ class Actions(object): from Peer import Peer logging.info("Pinging 5 times peer: %s:%s..." % (peer_ip, int(peer_port))) + s = time.time() peer = Peer(peer_ip, peer_port) + peer.connect() + + if not peer.connection: + print "Error: Can't connect to peer (connection error: %s)" % peer.connection_error + return False + print "Connection time: %.3fs (connection error: %s)" % (time.time() - s, peer.connection_error) + for i in range(5): print "Response time: %.3fs (crypt: %s)" % (peer.ping(), peer.connection.crypt) time.sleep(1)