1
0

handle network.interface being None when network is disconnected

This commit is contained in:
ThomasV
2013-10-04 19:27:50 +02:00
parent ac956a97cb
commit a38298c5ee
4 changed files with 20 additions and 11 deletions

View File

@@ -92,7 +92,11 @@ class Blockchain(threading.Thread):
print_error("error", i.server)
# todo: dismiss that server
h = self.servers_height.get(self.network.interface.server)
if self.network.is_connected():
h = self.servers_height.get(self.network.interface.server)
else:
h = None
if h is not None and h < height - 1:
print_error( "Server is lagging", height, h)
if self.config.get('auto_cycle'):

View File

@@ -166,6 +166,11 @@ class Network(threading.Thread):
return self.interface.is_connected
def wait_until_connected(self):
while not self.interface:
time.sleep(1)
self.interface.connect_event.wait()
def set_proxy(self, proxy):
self.proxy = proxy
@@ -175,7 +180,9 @@ class Network(threading.Thread):
return
# stop the interface in order to terminate subscriptions
self.interface.stop()
if self.interface:
self.interface.stop()
# notify gui
self.trigger_callback('disconnecting')
# start interface

View File

@@ -1510,12 +1510,12 @@ class WalletSynchronizer(threading.Thread):
self.running = True
while self.is_running():
interface = self.network.interface
if not interface.is_connected:
if not self.network.is_connected():
print_error("synchronizer: waiting for interface")
interface.connect_event.wait()
self.network.wait_until_connected()
self.run_interface(interface)
self.run_interface(self.network.interface)
def run_interface(self, interface):