Browse Source

exit wait_until_connected() when all servers have been tried

283
ecdsa 11 years ago
parent
commit
d140383d03
  1. 3
      lib/network.py
  2. 4
      scripts/peers

3
lib/network.py

@ -177,7 +177,8 @@ class Network(threading.Thread):
def wait_until_connected(self):
"wait until connection status is known"
if self.config.get('auto_cycle'):
while not self.is_connected():
# self.random_server() returns None if all servers have been tried
while not self.is_connected() and self.random_server():
time.sleep(0.1)
else:
self.interface.connect_event.wait()

4
scripts/peers

@ -3,11 +3,11 @@
import time, electrum
electrum.set_verbosity(False) # default is True
network = electrum.Network({'verbose':False})
network = electrum.Network({'auto_cycle':True})
network.register_callback('peers',lambda: electrum.print_json(network.irc_servers.keys()))
if not network.start(wait=True):
print "Not connected [%s]"% network.interface.server
print "Not connected"
exit(1)
print "Connected to", network.interface.server

Loading…
Cancel
Save