X-Git-Url: https://git.novaco.in/?p=electrum-server.git;a=blobdiff_plain;f=backends%2Fbitcoind%2Fblockchain_processor.py;h=0a133db4af792e7d24f02562cfb49d68a88a91b9;hp=421f385cb7859bd82098bbf53046ff331d4e1d0b;hb=b781bb56313255e668fffe45a09ed330a9887c13;hpb=6adb33a7221351f84357c89bc7ae0d17b1d73ffa diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 421f385..0a133db 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -87,7 +87,8 @@ class BlockchainProcessor(Processor): self.memorypool_update() print_log("Memory pool initialized.") - threading.Timer(10, self.main_iteration).start() + self.timer = threading.Timer(10, self.main_iteration) + self.timer.start() @@ -514,7 +515,7 @@ class BlockchainProcessor(Processor): result = self.storage.get_address(txi) except BaseException, e: error = str(e) - print_log("error:", error, txid, pos) + print_log("error:", error, params) elif method == 'blockchain.block.get_header': if cache_only: @@ -748,10 +749,17 @@ class BlockchainProcessor(Processor): # TODO: update cache here. if new value equals cached value, do not send notification self.address_queue.put((address,sessions)) + + def close(self): + self.timer.join() + print_log("Closing database...") + self.storage.close() + print_log("Database is closed") + + def main_iteration(self): if self.shared.stopped(): - print_log("blockchain processor terminating") - self.storage.close() + print_log("Stopping timer") return with self.dblock: @@ -794,7 +802,7 @@ class BlockchainProcessor(Processor): 'params': [addr, status], }) - if not self.shared.stopped(): - threading.Timer(10, self.main_iteration).start() - else: - print_log("blockchain processor terminating") + # next iteration + self.timer = threading.Timer(10, self.main_iteration) + self.timer.start() +