From 433d55d35191a708632173de90f4ca6fbfd7ba4f Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 3 Jun 2013 01:04:22 -0400 Subject: [PATCH] Low priority POW threads --- src/bitmessagemain.py | 2 +- src/proofofwork.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index c7ce958e..100d6d30 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -3822,7 +3822,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): queryreturn = shared.sqlReturnQueue.get() shared.sqlLock.release() if queryreturn == []: - return 'notFound' + return 'notfound' for row in queryreturn: status, = row return status diff --git a/src/proofofwork.py b/src/proofofwork.py index 20abf169..5aef6dc4 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -3,8 +3,21 @@ import time from multiprocessing import Pool, cpu_count import hashlib from struct import unpack, pack +import sys +import os + +def _set_idle(): + try: + sys.getwindowsversion() + import win32api,win32process,win32con + pid = win32api.GetCurrentProcessId() + handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid) + win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS) + except: + os.nice(20) def _pool_worker(nonce, initialHash, target, pool_size): + _set_idle() trialValue = 99999999999999999999 while trialValue > target: nonce += pool_size