aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/concurrent/futures/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/concurrent/futures/__init__.py')
-rw-r--r--Lib/concurrent/futures/__init__.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/Lib/concurrent/futures/__init__.py b/Lib/concurrent/futures/__init__.py
index 7ada7431c1a..e717222cf98 100644
--- a/Lib/concurrent/futures/__init__.py
+++ b/Lib/concurrent/futures/__init__.py
@@ -17,7 +17,7 @@ from concurrent.futures._base import (FIRST_COMPLETED,
wait,
as_completed)
-__all__ = (
+__all__ = [
'FIRST_COMPLETED',
'FIRST_EXCEPTION',
'ALL_COMPLETED',
@@ -29,10 +29,18 @@ __all__ = (
'Executor',
'wait',
'as_completed',
- 'InterpreterPoolExecutor',
'ProcessPoolExecutor',
'ThreadPoolExecutor',
-)
+]
+
+
+try:
+ import _interpreters
+except ImportError:
+ _interpreters = None
+
+if _interpreters:
+ __all__.append('InterpreterPoolExecutor')
def __dir__():
@@ -43,22 +51,15 @@ def __getattr__(name):
global ProcessPoolExecutor, ThreadPoolExecutor, InterpreterPoolExecutor
if name == 'ProcessPoolExecutor':
- from .process import ProcessPoolExecutor as pe
- ProcessPoolExecutor = pe
- return pe
+ from .process import ProcessPoolExecutor
+ return ProcessPoolExecutor
if name == 'ThreadPoolExecutor':
- from .thread import ThreadPoolExecutor as te
- ThreadPoolExecutor = te
- return te
+ from .thread import ThreadPoolExecutor
+ return ThreadPoolExecutor
- if name == 'InterpreterPoolExecutor':
- try:
- from .interpreter import InterpreterPoolExecutor as ie
- except ModuleNotFoundError:
- ie = InterpreterPoolExecutor = None
- else:
- InterpreterPoolExecutor = ie
- return ie
+ if _interpreters and name == 'InterpreterPoolExecutor':
+ from .interpreter import InterpreterPoolExecutor
+ return InterpreterPoolExecutor
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")