File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 Executor ,
1616 wait ,
1717 as_completed )
18- from concurrent .futures .process import ProcessPoolExecutor
19- from concurrent .futures .thread import ThreadPoolExecutor
18+
19+ __all__ = (
20+ 'FIRST_COMPLETED' ,
21+ 'FIRST_EXCEPTION' ,
22+ 'ALL_COMPLETED' ,
23+ 'CancelledError' ,
24+ 'TimeoutError' ,
25+ 'BrokenExecutor' ,
26+ 'Future' ,
27+ 'Executor' ,
28+ 'wait' ,
29+ 'as_completed' ,
30+ 'ProcessPoolExecutor' ,
31+ 'ThreadPoolExecutor' ,
32+ )
33+
34+
35+ def __dir__ ():
36+ return __all__ + ('__author__' , '__doc__' )
37+
38+
39+ def __getattr__ (name ):
40+ global ProcessPoolExecutor , ThreadPoolExecutor
41+
42+ if name == 'ProcessPoolExecutor' :
43+ from .process import ProcessPoolExecutor
44+ return ProcessPoolExecutor
45+
46+ if name == 'ThreadPoolExecutor' :
47+ from .thread import ThreadPoolExecutor
48+ return ThreadPoolExecutor
49+
50+ raise AttributeError (f"module { __name__ } has no attribute { name } " )
Original file line number Diff line number Diff line change 1+ ``concurrent.futures `` imports ``ThreadPoolExecutor `` and
2+ ``ProcessPoolExecutor `` lazily (using :pep: `562 `).
3+ It makes ``import asyncio `` about 15% faster because asyncio
4+ uses only ``ThreadPoolExecutor `` by default.
You can’t perform that action at this time.
0 commit comments