The concurrent.futures module, which is part of the standard Python library, provides a level of abstraction on threads by modelling them as asynchronous functions.
This module is built by two main classes:
- concurrent.futures.Executor: This is an abstract class that provides methods to execute calls asynchronously.
- concurrent.futures.Future: This encapsulates the asynchronous execution of a callable. Future objects are instantiated by submitting tasks (functions with optional parameters) to Executors.
Here are some of the main methods of the module:
- submit(function,argument): This schedules the execution of the callable function on the arguments.
- map(function,argument): This executes the functions of arguments in asynchronous mode.
- shutdown(Wait=True): This signals the executor to free any resource.
The executors are...