From b8a08a0ce9415dbec6b4869d5b78c2b5938997c7 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Thu, 30 Jun 2016 23:03:39 +0200 Subject: [PATCH] Fix python PoW - recent changes cause the pool workers to trigger shutdown and freeze. Now python PoW works again --- src/proofofwork.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/proofofwork.py b/src/proofofwork.py index 9d53b39e..3bc99c83 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -60,10 +60,22 @@ def _doFastPoW(target, initialHash): maxCores = 99999 if pool_size > maxCores: pool_size = maxCores + + # temporarily disable handlers + int_handler = signal.getsignal(signal.SIGINT) + term_handler = signal.getsignal(signal.SIGTERM) + signal.signal(signal.SIGINT, signal.SIG_IGN) + signal.signal(signal.SIGTERM, signal.SIG_IGN) + pool = Pool(processes=pool_size) result = [] for i in range(pool_size): result.append(pool.apply_async(_pool_worker, args = (i, initialHash, target, pool_size))) + + # re-enable handlers + signal.signal(signal.SIGINT, int_handler) + signal.signal(signal.SIGTERM, term_handler) + while True: if shutdown >= 1: pool.terminate()