Python池图和选择进程数 [英] Python pool map and choosing number of processes
问题描述
在设置进程数时,我很想看看我的机器上实际可以使用多少个线程-如何找到这个?有没有办法确定我可用的线程数?
In setting the number of processes, I'd be keen to see how many threads I can actually use on my machine - how do I find this? Is there a way to determine the number of threads available to me?
推荐答案
您是否想知道 CPU数量?
根据 docs ,您启动一个池并且不区分进程数量,默认数量是系统上的cpu数量:
According to the docs, when you start a pool and don't sepecify the number of processes, the default number is the number of cpu's on the system:
processes是要使用的辅助进程数.如果进程为
None
,则使用cpu_count()
返回的数字.如果初始值设定项不为None,则每个工作进程在启动时都会调用初始值设定项(* initargs).
processes is the number of worker processes to use. If processes is
None
then the number returned bycpu_count()
is used. If initializer is not None then each worker process will call initializer(*initargs) when it starts.
这篇关于Python池图和选择进程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!