Skip to content

Commit e4d636e

Browse files
author
foreverneilyoung
committed
Raised thread priority for tracer (problems in Win64 console)
1 parent 7387b8e commit e4d636e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

core/tracer.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
# based on the Windows GUI exe with same name
99
##################################################################################
1010

11-
import threading, urllib
11+
import threading, urllib, ctypes, platform
1212
import util
1313

14+
THREAD_SET_INFORMATION = 0x20
15+
THREAD_PRIORITY_ABOVE_NORMAL = 1
16+
17+
1418
''' Tracer runs in a separate thread'''
1519
class Tracer(threading.Thread):
1620
def __init__(self, url, filename):
@@ -26,8 +30,18 @@ def monitor(self, n1, n2, n3):
2630
self.i %= 4
2731

2832
def run(self):
33+
if platform.system() == "Windows":
34+
w32 = ctypes.windll.kernel32
35+
tid = w32.GetCurrentThreadId()
36+
# Raise thread priority
37+
handle = w32.OpenThread(THREAD_SET_INFORMATION, False, tid)
38+
result = w32.SetThreadPriority(handle, THREAD_PRIORITY_ABOVE_NORMAL)
39+
w32.CloseHandle(handle)
2940
try:
3041
urllib.urlretrieve(self.url, self.filename, self.monitor)
3142
util.log('Trace finished server side')
3243
except:
3344
util.log('Could not open %s' % self.url)
45+
46+
47+

0 commit comments

Comments
 (0)