python (3.11.7)
1 # Copyright 2009 Brian Quinlan. All Rights Reserved.
2 # Licensed to PSF under a Contributor Agreement.
3
4 """Execute computations asynchronously using threads or processes."""
5
6 __author__ = 'Brian Quinlan (brian@sweetapp.com)'
7
8 from concurrent.futures._base import (FIRST_COMPLETED,
9 FIRST_EXCEPTION,
10 ALL_COMPLETED,
11 CancelledError,
12 TimeoutError,
13 InvalidStateError,
14 BrokenExecutor,
15 Future,
16 Executor,
17 wait,
18 as_completed)
19
20 __all__ = (
21 'FIRST_COMPLETED',
22 'FIRST_EXCEPTION',
23 'ALL_COMPLETED',
24 'CancelledError',
25 'TimeoutError',
26 'BrokenExecutor',
27 'Future',
28 'Executor',
29 'wait',
30 'as_completed',
31 'ProcessPoolExecutor',
32 'ThreadPoolExecutor',
33 )
34
35
36 def __dir__():
37 return __all__ + ('__author__', '__doc__')
38
39
40 def __getattr__(name):
41 global ProcessPoolExecutor, ThreadPoolExecutor
42
43 if name == 'ProcessPoolExecutor':
44 from .process import ProcessPoolExecutor as pe
45 ProcessPoolExecutor = pe
46 return pe
47
48 if name == 'ThreadPoolExecutor':
49 from .thread import ThreadPoolExecutor as te
50 ThreadPoolExecutor = te
51 return te
52
53 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")