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 try:
38 import _interpreters
39 except ImportError:
40 _interpreters = None
41
42 if _interpreters:
43 __all__.append('InterpreterPoolExecutor')
44
45
46 def __dir__():
47 return __all__ + ['__author__', '__doc__']
48
49
50 def __getattr__(name):
51 global ProcessPoolExecutor, ThreadPoolExecutor, InterpreterPoolExecutor
52
53 if name == 'ProcessPoolExecutor':
54 from .process import ProcessPoolExecutor
55 return ProcessPoolExecutor
56
57 if name == 'ThreadPoolExecutor':
58 from .thread import ThreadPoolExecutor
59 return ThreadPoolExecutor
60
61 if _interpreters and name == 'InterpreterPoolExecutor':
62 from .interpreter import InterpreterPoolExecutor
63 return InterpreterPoolExecutor
64
65 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")