Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiprocessing and niceness value

Does anyone know of an easy way to set the niceness value of a Process or Pool when it is created in multiprocessing?

like image 478
myurko Avatar asked Feb 02 '10 00:02

myurko


People also ask

Is multiprocessing faster?

So, multiprocessing is faster when the program is CPU-bound. In cases where there is a lot of I/O in your program, threading may be more efficient because most of the time, your program is waiting for the I/O to complete. However, multiprocessing is generally more efficient because it runs concurrently.

Does multiprocessing speed up Python?

It is used to significantly speed up your program, especially if it has a lot of CPU extensive tasks. In this case, multiple functions can run together because each one will use a different CPU core which in turn will improve the CPU utilization.

Why multiprocessing is slow in Python?

The multiprocessing version is slower because it needs to reload the model in every map call because the mapped functions are assumed to be stateless. The multiprocessing version looks as follows. Note that in some cases, it is possible to achieve this using the initializer argument to multiprocessing.


1 Answers

os.nice(increment)
Add increment to the process’s “niceness”. Return the new niceness. Availability: Unix.

From http://docs.python.org/library/os.html#os.nice.

Is there a reason you can't call this in the child process?

like image 105
richo Avatar answered Nov 15 '22 21:11

richo