toptional wait parameter for interface - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 837150132d64f36c0037acf1f528e7264064ed89 DIR parent 49a4c6c92a2ff8526a03f04e6c155d44f7a828ff HTML Author: ecdsa <ecdsa@github> Date: Sun, 10 Mar 2013 10:24:42 +0100 optional wait parameter for interface Diffstat: M electrum | 13 ++----------- M lib/interface.py | 9 +++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) --- DIR diff --git a/electrum b/electrum t@@ -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) t@@ -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) t@@ -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) DIR diff --git a/lib/interface.py b/lib/interface.py t@@ -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()