Using the submit method
Sometimes, the map method is too simple. What if we want to handle the results as each worker produces them, instead of waiting for all the workers to get done? What if we decide not to run the function after all? What if we want to run different functions in worker processes at the same time? For that matter, what if we want to pass keyword arguments to the function? We could do all that and more using the submit method.
Each call to the submit method translates to a single call to the function that we pass as the first parameter of the submit method. The rest of the parameters and keyword arguments we pass to submit are passed into the function after being sent to the worker process.
Let's look at an example of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access