Commit 70727b20 authored by Guillaume Seguin's avatar Guillaume Seguin

Pass os.getpid() to psutil.Process for psutil<1.2 (#284)

parent d95a66f0
......@@ -15,6 +15,7 @@
import platform
import traceback
import os
if platform.system() == "Darwin":
from .osx import inhibit_sleep_osx, deinhibit_sleep_osx
......@@ -60,19 +61,18 @@ else:
try:
import psutil
def set_nice(p, nice):
def set_nice(nice):
p = psutil.Process(os.getpid())
if callable(p.nice):
p.nice(nice)
else:
p.nice = nice
def set_priority():
p = psutil.Process()
set_nice(p, 10 if platform.system() != "Windows" else psutil.HIGH_PRIORITY_CLASS)
set_nice(10 if platform.system() != "Windows" else psutil.HIGH_PRIORITY_CLASS)
def reset_priority():
p = psutil.Process()
set_nice(p, 0 if platform.system() != "Windows" else psutil.NORMAL_PRIORITY_CLASS)
set_nice(0 if platform.system() != "Windows" else psutil.NORMAL_PRIORITY_CLASS)
def powerset_print_start(reason):
set_priority()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment