Using the concurrent.futures Python modules
With the release of Python 3.2, the concurrent.future
module was introduced, which allows us to manage concurrent programming tasks, such as process and thread pooling, nondeterministic execution flows, and processes and thread synchronization.
This package is built by the following classes:
concurrent.futures.Executor
: This is an abstract class that provides methods to execute calls asynchronously.submit (function ,argument)
: This schedules the execution of a function (called callable) on the arguments.map (function,argument)
: This executes the function on arguments in an asynchronous mode.shutdown (Wait = True)
: This signals the executor to free any resource.concurrent.futures.Future
: This encapsulates the asynchronous execution of a callable function. Future objects are instantiated by submitting tasks (functions with optional parameters) to executors.
Executors are abstractions that are accessed through their subclasses: thread or process...