Debian Codegraph @

Lib/concurrent/futures/__init__.py

raw
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 ([email protected])'
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 'InvalidStateError',
27 'BrokenExecutor',
28 'Future',
29 'Executor',
30 'wait',
31 'as_completed',
32 'ProcessPoolExecutor',
33 'ThreadPoolExecutor',
34 )
35
36
37 def __dir__():
38 return __all__ + ('__author__', '__doc__')
39
40
41 def __getattr__(name):
42 global ProcessPoolExecutor, ThreadPoolExecutor
43
44 if name == 'ProcessPoolExecutor':
45 from .process import ProcessPoolExecutor as pe
46 ProcessPoolExecutor = pe
47 return pe
48
49 if name == 'ThreadPoolExecutor':
50 from .thread import ThreadPoolExecutor as te
51 ThreadPoolExecutor = te
52 return te
53
54 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")