concurrent.future Module
1 Thread Module /Thread Module
1.1 Constants /Constants
Pass
1.2 function /Function
Pass
1.3 class /Class
1.3.1 Threadpoolexecutor class
class Instantiation: Executor = threadpoolexecutor (Max_works)
functions of the class : used to generate an instance of a thread pool executor whose base class is _base. Executor
Incoming Parameters : Max_works
Max_works:int type, number of thread pool max threads
return Parameters : Executor
Executor:instance type, thread pool executor instance
1.3.1.1 Submit () function
function Call : Executor.submit (FN, *args)
function function : starts a thread in the thread pool, invokes the incoming FN function and its arguments
Incoming Parameters : FN, *args
Fn:function type, the passed-in function, called by thread-pool-initiated threads
*ARGS:FN required parameters, when there are multiple, incoming mode is submit (FN, Args_1, args_2, Args_3)
return Parameters : No
1.3.1.2 map () function
function Call : iter = Executor.map (FN, *iterables, Timeout=none)
function function : Returns an iterative generator, analogous to map (FN, *iterables), which belongs to the base class executor method
Incoming Parameters : FN, *args, timeout
Fn:function type, the passed-in function, called by thread-pool-initiated threads
*iterables:list/tuple types, such as iterations, are fetched by iteration and passed into the FN function. When there are multiple parameters, the incoming mode is map (FN, [A_args_1, A_args_2, ..., A_args_n], [B_args_1, B_args_2, ..., B_args_n], iterable_3), and map iterates over the generator, Passing parameters to FN separately
return Parameters : Iter
The Iter:generator type, which automatically calls the function to iterate randomly, leaving none after the end
2 Process Module /Process Module
TBD
Python concurrency parallel [4]--concurrent.future module