Using apply() to make a single request

In addition to the map() function's variants, a pool also has an apply(function, *args, **kw) method that we can use to pass one value to the worker pool. We can see that the map() method is really just a for loop wrapped around the apply() method. We can, for example, use the following command:

list(    workers.apply(analysis, f)     for f in glob.glob(pattern))

It's not clear, for our purposes, that this is a significant improvement. Almost everything we need to do can be expressed as a map() function.

Get Functional Python Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.