Skip to content

Commit

Permalink
FIX: Niceness is now no longer decremented under Linux;
Browse files Browse the repository at this point in the history
  • Loading branch information
SmokinCaterpillar committed Dec 15, 2015
1 parent 2b0dccd commit 62ef655
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pypet/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,17 @@ def _configure_niceness(kwargs):
niceness = kwargs['niceness']
if niceness is not None:
try:
current = os.nice(0)
os.nice(niceness-current)
except AttributeError:
# Fall back on psutil under Windows
psutil.Process().nice(niceness)

try:
current = os.nice(0)
if niceness - current > 0:
# Under Linux you cannot decrement niceness if set elsewhere
os.nice(niceness-current)
except AttributeError:
# Fall back on psutil under Windows
psutil.Process().nice(niceness)
except Exception as exc:
sys.stderr.write('Could not configure niceness because of: %s' % repr(exc))
traceback.print_exc()

def _sigint_handling_single_run(kwargs):
"""Wrapper that allow graceful exits of single runs"""
Expand Down

0 comments on commit 62ef655

Please sign in to comment.