lower process priority
This commit is contained in:
parent
9f8ac737db
commit
928850c2a8
1
onn.py
1
onn.py
|
@ -991,6 +991,7 @@ def model_from_config(config, input_features, output_features, callbacks):
|
|||
def run(program, args=None):
|
||||
args = args if args else []
|
||||
|
||||
lower_priority()
|
||||
np.random.seed(42069)
|
||||
|
||||
# Config {{{2
|
||||
|
|
18
onn_core.py
18
onn_core.py
|
@ -4,6 +4,24 @@ import types
|
|||
def lament(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
def lower_priority():
|
||||
"""Set the priority of the process to below-normal."""
|
||||
# via https://stackoverflow.com/a/1023269
|
||||
if sys.platform == 'win32':
|
||||
try:
|
||||
import win32api, win32process, win32con
|
||||
pid = win32api.GetCurrentProcessId()
|
||||
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
|
||||
win32process.SetPriorityClass(handle, win32process.BELOW_NORMAL_PRIORITY_CLASS)
|
||||
except ImportError:
|
||||
lament("you do not have pywin32 installed.")
|
||||
lament("the process priority could not be lowered.")
|
||||
lament("consider: python -m pip install pypiwin32")
|
||||
lament("consider: conda install pywin32")
|
||||
else:
|
||||
import os
|
||||
os.nice(1)
|
||||
|
||||
import numpy as np
|
||||
_f = np.float32
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from onn import *
|
|||
from onn_core import _f
|
||||
from dotmap import DotMap
|
||||
|
||||
lower_priority()
|
||||
#np.random.seed(42069)
|
||||
|
||||
use_emnist = True
|
||||
|
|
Loading…
Reference in New Issue
Block a user