Skip to content

Commit 30a34dd

Browse files
committed
Simplify the try import codes
1 parent 0f1c7b2 commit 30a34dd

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

Lib/concurrent/futures/__init__.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@
3434
]
3535

3636

37-
_have__interpreters = False
37+
_interpreters = None
3838

3939
try:
4040
import _interpreters
41-
_have__interpreters = True
4241
except ModuleNotFoundError:
4342
pass
4443

45-
if _have__interpreters:
44+
if _interpreters:
4645
__all__.append('InterpreterPoolExecutor')
4746

4847

@@ -54,16 +53,14 @@ def __getattr__(name):
5453
global ProcessPoolExecutor, ThreadPoolExecutor, InterpreterPoolExecutor
5554

5655
if name == 'ProcessPoolExecutor':
57-
from .process import ProcessPoolExecutor as pe
58-
ProcessPoolExecutor = pe
59-
return pe
56+
from .process import ProcessPoolExecutor
57+
return ProcessPoolExecutor
6058

6159
if name == 'ThreadPoolExecutor':
62-
from .thread import ThreadPoolExecutor as te
63-
ThreadPoolExecutor = te
64-
return te
60+
from .thread import ThreadPoolExecutor
61+
return ThreadPoolExecutor
6562

66-
if _have__interpreters and name == 'InterpreterPoolExecutor':
63+
if _interpreters and name == 'InterpreterPoolExecutor':
6764
from .interpreter import InterpreterPoolExecutor
6865
return InterpreterPoolExecutor
6966

0 commit comments

Comments
 (0)