Skip to content

Commit 7508c73

Browse files
committed
Fix import start
1 parent cc1a90a commit 7508c73

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

Lib/concurrent/futures/__init__.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
wait,
1818
as_completed)
1919

20-
__all__ = (
20+
__all__ = [
2121
'FIRST_COMPLETED',
2222
'FIRST_EXCEPTION',
2323
'ALL_COMPLETED',
@@ -29,22 +29,29 @@
2929
'Executor',
3030
'wait',
3131
'as_completed',
32-
'InterpreterPoolExecutor',
3332
'ProcessPoolExecutor',
3433
'ThreadPoolExecutor',
35-
)
34+
]
3635

3736

38-
def __dir__():
39-
return __all__ + ('__author__', '__doc__')
37+
_have__interpreters = False
38+
39+
try:
40+
import _interpreters
41+
_have__interpreters = True
42+
except ModuleNotFoundError:
43+
pass
4044

45+
if _have__interpreters:
46+
__all__.append('InterpreterPoolExecutor')
4147

42-
_no_interpreter_pool_executor = False
48+
49+
def __dir__():
50+
return __all__ + ('__author__', '__doc__')
4351

4452

4553
def __getattr__(name):
4654
global ProcessPoolExecutor, ThreadPoolExecutor, InterpreterPoolExecutor
47-
global _no_interpreter_pool_executor
4855

4956
if name == 'ProcessPoolExecutor':
5057
from .process import ProcessPoolExecutor as pe
@@ -56,13 +63,9 @@ def __getattr__(name):
5663
ThreadPoolExecutor = te
5764
return te
5865

59-
if name == 'InterpreterPoolExecutor' and not _no_interpreter_pool_executor:
60-
try:
61-
from .interpreter import InterpreterPoolExecutor as ie
62-
except ModuleNotFoundError:
63-
_no_interpreter_pool_executor = True
64-
else:
65-
InterpreterPoolExecutor = ie
66-
return ie
66+
if _have__interpreters and name == 'InterpreterPoolExecutor':
67+
from .interpreter import InterpreterPoolExecutor as ie
68+
InterpreterPoolExecutor = ie
69+
return ie
6770

6871
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

0 commit comments

Comments
 (0)