0

In the python docs for the multiprocessing module the very first example is about the Pool command.

from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, [1, 2, 3]))

This script is used to demonstrate how the Pool method can be used to run the same function in parallel for a series of possible arguments.

They do not, however explain or provide the arguments to the Pool method, which in this case equals 5.

What is that argument? Why is it 5 in this case? Does it have something to do with the number of allowed processes at a given time?

Thanks

1 Answer 1

1

You are not reading the documentation of Pool, you are reading just a simple example.

The real documentation of Pool is here, where the meaning of the number is clearly explained:

processes is the number of worker processes to use. If processes is None then the number returned by os.cpu_count() is used.

Sign up to request clarification or add additional context in comments.

1 Comment

I suspected there had to be more information out there. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.