Python池图和选择进程数 [英] Python pool map and choosing number of processes

查看:96
本文介绍了Python池图和选择进程数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设置进程数时,我很想看看我的机器上实际可以使用多少个线程-如何找到这个?有没有办法确定我可用的线程数?

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 by cpu_count() is used. If initializer is not None then each worker process will call initializer(*initargs) when it starts.

这篇关于Python池图和选择进程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆