From 5572176f7cfc7aa6aefec838c9524f99020a96d2 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 28 Apr 2016 17:35:05 +0200 Subject: [PATCH] poison pill --- bigchaindb/voter.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bigchaindb/voter.py b/bigchaindb/voter.py index 5f89232c..1fba5622 100644 --- a/bigchaindb/voter.py +++ b/bigchaindb/voter.py @@ -213,6 +213,11 @@ class Election(object): while True: next_block = self.q_block_new_vote.get() + # poison pill + if next_block == 'stop': + logger.info('clean exit') + return + if b.block_voted_invalid(next_block): self.q_invalid_blocks.put(next_block) @@ -227,6 +232,12 @@ class Election(object): for tx in invalid_block['transactions']: b.write_transaction(tx) + def kill(self): + """ + Terminate processes + """ + self.q_block_new_vote.put('stop') + def start(self): """ Initialize, spawn, and start the processes