commit 837150132d64f36c0037acf1f528e7264064ed89
parent 49a4c6c92a2ff8526a03f04e6c155d44f7a828ff
Author: ecdsa <ecdsa@github>
Date: Sun, 10 Mar 2013 10:24:42 +0100
optional wait parameter for interface
Diffstat:
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/electrum b/electrum
@@ -124,7 +124,7 @@ if __name__ == '__main__':
interface = Interface(config, True)
wallet.interface = interface
- interface.start()
+ interface.start(wait = False)
interface.send([('server.peers.subscribe',[])])
gui = gui.ElectrumGui(wallet, config)
@@ -239,11 +239,7 @@ if __name__ == '__main__':
if not options.offline:
interface = Interface(config)
- interface.start()
- interface.connect_event.wait()
- if not interface.is_connected:
- print_msg("Not connected, aborting.")
- sys.exit(1)
+ interface.start(wait=True)
wallet.interface = interface
verifier = WalletVerifier(interface, config)
wallet.set_verifier(verifier)
@@ -361,11 +357,6 @@ if __name__ == '__main__':
interface = Interface(config)
interface.register_callback('connected', lambda: sys.stderr.write("Connected to " + interface.connection_msg + "\n"))
interface.start()
- # wait until connected
- interface.connect_event.wait()
- if not interface.is_connected:
- print_msg("Not connected, aborting.")
- sys.exit(1)
wallet.interface = interface
verifier = WalletVerifier(interface, config)
wallet.set_verifier(verifier)
diff --git a/lib/interface.py b/lib/interface.py
@@ -586,6 +586,15 @@ class Interface(threading.Thread):
return out
+ def start(self, wait=True):
+ threading.Thread.start(self)
+ if wait:
+ # wait until connection is established
+ self.connect_event.wait()
+ if not self.is_connected:
+ print_msg("Not connected, aborting.")
+ sys.exit(1)
+
def run(self):
while True:
self.init_interface()