renice

M

mokhtar

Hi

Is it possible to renice the python process executing the current python
script ?:confused:
 
C

Carl Banks

On UNIX:>>> import os


Hmm. That seems to be the hard way, since you can set the nice value
of the current process (almost) directly:

import os
nice_adder = new_nice - os.nice(0)
os.nice(nice_adder)


But I suppose it could be useful in situations where you need
privleges you don't currently have. E.g.:

os.system("sudo renice -n %s %s" % (new_nice, os.getpid()))


Carl Banks
 
J

JonPeirce

Note that with os.nice you can only *decrease* priority. For increasing
priority you need to run;
os.system("sudo renice -n %s %s" % (new_nice, os.getpid()))
or simply set the nice level when you run python in the first place (you do
also need sudo for this):
sudo nice -n -15 python myScript.py

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top