Handle connection errors when running peerPing command
This commit is contained in:
parent
7b1601c840
commit
8998bf85bd
1 changed files with 8 additions and 0 deletions
|
@ -461,7 +461,15 @@ class Actions(object):
|
||||||
|
|
||||||
from Peer import Peer
|
from Peer import Peer
|
||||||
logging.info("Pinging 5 times peer: %s:%s..." % (peer_ip, int(peer_port)))
|
logging.info("Pinging 5 times peer: %s:%s..." % (peer_ip, int(peer_port)))
|
||||||
|
s = time.time()
|
||||||
peer = Peer(peer_ip, peer_port)
|
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):
|
for i in range(5):
|
||||||
print "Response time: %.3fs (crypt: %s)" % (peer.ping(), peer.connection.crypt)
|
print "Response time: %.3fs (crypt: %s)" % (peer.ping(), peer.connection.crypt)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
Loading…
Reference in a new issue