poison pill

This commit is contained in:
ryan 2016-04-28 17:35:05 +02:00
parent 8ab1cfdfa1
commit 5572176f7c

View File

@ -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