多进程与亲和度值

13 投票
2 回答
2445 浏览
提问于 2025-04-15 18:45

有没有人知道在使用多进程创建进程或进程池时,怎么简单地设置它的优先级值?

2 个回答

0

试着导入ctypes模块,然后查找pthread_schedparam()或SetThreadPriority()这两个函数(分别用于Linux和Windows)。

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

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

有没有什么原因让你不能在子进程中调用这个?

撰写回答