Python multiprocessing's Pool process limit

后端 未结 4 1774
你的背包
你的背包 2020-12-08 01:57

In using the Pool object from the multiprocessing module, is the number of processes limited by the number of CPU cores? E.g. if I have 4 cores, even if I create a Pool with

4条回答
  •  我在风中等你
    2020-12-08 02:53

    While there is no limit you can set, if you are looking to understand a convenient number to use for CPU bound processes (which I suspect you are looking for here), you can run the following:

    >>> import multiprocessing
    >>> multiprocessing.cpu_count()
    1
    

    Some good notes on limitations (especially in linux) are noted in the answer here:

提交回复
热议问题