File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 wait ,
1818 as_completed )
1919
20- __all__ = (
20+ __all__ = [
2121 'FIRST_COMPLETED' ,
2222 'FIRST_EXCEPTION' ,
2323 'ALL_COMPLETED' ,
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
4553def __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} " )
You can’t perform that action at this time.
0 commit comments