我正在尝试找到一种直接从一个实例中获取过程数的方法 multiprocessing.Pool python的课程..有没有办法做到这一点?

该文档没有显示任何相关的内容。

谢谢

有帮助吗?

解决方案

您可以使用 _processes 属性:

>>> import multiprocessing
>>> pool = multiprocessing.Pool()
>>> pool._processes
8

返回值相同 multiprocessing.cpu_count() 除非您在创建时指定过程计数 Pool 目的。

>>> multiprocessing.cpu_count()
8
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top