electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9afbf211973840cfdc794b1342e27cb7f71da6c8
parent 0ad7f72d3d2a2f473916ade21db5bfc680d7d0d2
Author: ThomasV <thomasv@gitorious>
Date:   Sat, 24 Nov 2012 20:31:07 +0100

no daemon

Diffstat:
Melectrum | 7+++++--
Mlib/interface.py | 5+++++
Mlib/verifier.py | 4+++-
Mlib/wallet.py | 11++++-------
4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/electrum b/electrum @@ -230,7 +230,8 @@ if __name__ == '__main__': verifier = WalletVerifier(interface, config) wallet.set_verifier(verifier) - WalletSynchronizer(wallet, config).start() + synchronizer = WalletSynchronizer(wallet, config) + synchronizer.start() if not found and a == 'restore' and s is not None: try: @@ -250,9 +251,11 @@ if __name__ == '__main__': verifier.start() gui.main(url) wallet.save() + verifier.stop() synchronizer.stop() - #interface.stop() + interface.stop() + sys.exit(0) if cmd not in known_commands: diff --git a/lib/interface.py b/lib/interface.py @@ -495,6 +495,11 @@ class Interface(threading.Thread): self.is_connected = False # this exits the polling loop self.trigger_callback('disconnecting') # for actively disconnecting + def stop(self): + if self.protocol in 'st' and self.s: + self.s.shutdown(socket.SHUT_RDWR) + self.s.close() + def get_servers_list(self): plist = {} diff --git a/lib/verifier.py b/lib/verifier.py @@ -65,6 +65,7 @@ class WalletVerifier(threading.Thread): def stop(self): with self.lock: self.running = False + self.interface.poke('verifier') def is_running(self): with self.lock: return self.running @@ -126,9 +127,10 @@ class WalletVerifier(threading.Thread): self.pending_headers.remove(header) try: - r = self.interface.get_response('verifier',timeout=0.1) + r = self.interface.get_response('verifier',timeout=1) except Queue.Empty: continue + if not r: continue # 3. handle response method = r['method'] diff --git a/lib/wallet.py b/lib/wallet.py @@ -1165,6 +1165,7 @@ class WalletSynchronizer(threading.Thread): def stop(self): with self.lock: self.running = False + self.interface.poke('synchronizer') def is_running(self): with self.lock: return self.running @@ -1233,14 +1234,10 @@ class WalletSynchronizer(threading.Thread): self.was_updated = False # 2. get a response - try: - r = self.interface.get_response('synchronizer', timeout=0.1) - except: - continue + r = self.interface.get_response('synchronizer') - # poke sends None. (check if still needed) - if not r: - continue + # poke sends None. (needed during stop) + if not r: continue # 3. handle response method = r['method']