giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.27k stars 1.38k forks source link

[Windows] OSError: [WinError 87] The parameter is incorrect #2204

Open phaniparsa opened 1 year ago

phaniparsa commented 1 year ago

Summary

Description

I am running the code available in this Git Repo: https://github.com/Merck/Line-of-Therapy-Algorithm/blob/master/Python/rwToT_LoT_main_parallel.py

and especially with the below lines of code: ctx = multiprocessing.get_context('spawn') pool = ctx.Pool(nprocesses) processes = [p.pid for p in pool._pool] for pid in processes: p = psutil.Process(pid) p.nice(5) pool_results = pool.map(process_chunk, input_chunk) pool.close()

When setting the niceness value for the process (process was created using multiprocessing), code is throwing the below error: image

Could you please confirm if this is Bug? If not, could anyone please help me in fixing me this error. Thank you.

giampaolo commented 1 year ago

What happens if instead of passing it a number (5) you pass one of the *_PRIORITY_CLASS constants? https://psutil.readthedocs.io/en/latest/#psutil.REALTIME_PRIORITY_CLASS