Using multiprocessing pools and tasks
To make non-strict evaluation available in a larger context, the multiprocessing
package introduces the concept of a Pool
object. We can create a Pool
object of concurrent worker processes, assign tasks to them, and expect the tasks to be executed concurrently. As noted previously, this creation does not actually mean simultaneous creation of Pool
objects. It means that the order is difficult to predict because we've allowed OS scheduling to interleave execution of multiple processes. For some applications, this permits more work to be done in less elapsed time.
To make the most use of this capability, we need to decompose our application into components for which non-strict concurrent execution is beneficial. ...
Get Functional Python Programming 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.