From a99e3d77801214bd4239dd4d920d93839423f56c Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Thu, 30 May 2013 16:42:24 -0400 Subject: [PATCH] Multi-core POW --- src/proofofwork.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proofofwork.py b/src/proofofwork.py index 144c7d79..20abf169 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -29,11 +29,11 @@ def run(target, initialHash): for i in range(pool_size): result.append(pool.apply_async(_pool_worker, args = (i, initialHash, target, pool_size))) while True: + if shared.shutdown: + pool.terminate() + time.sleep(5) #Don't return anything (doing so will cause exceptions because we'll return an unusable response). Sit here and wait for this thread to close. + return for i in range(pool_size): - if shared.shutdown: - pool.terminate() - time.sleep(5) #Don't return anything (doing so will cause exceptions because we'll return an unusable response). Sit here and wait for this thread to close. - return if result[i].ready(): result = result[i].get() pool.terminate()