Python concurrency parallel [4]--concurrent.future module

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.