Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions Lib/concurrent/futures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
wait,
as_completed)

__all__ = (
__all__ = [
'FIRST_COMPLETED',
'FIRST_EXCEPTION',
'ALL_COMPLETED',
Expand All @@ -29,10 +29,21 @@
'Executor',
'wait',
'as_completed',
'InterpreterPoolExecutor',
'ProcessPoolExecutor',
'ThreadPoolExecutor',
)
]


_have__interpreters = False

try:
import _interpreters
_have__interpreters = True
except ModuleNotFoundError:
pass

if _have__interpreters:
__all__.append('InterpreterPoolExecutor')


def __dir__():
Expand All @@ -52,13 +63,9 @@ def __getattr__(name):
ThreadPoolExecutor = te
return te

if name == 'InterpreterPoolExecutor':
try:
from .interpreter import InterpreterPoolExecutor as ie
except ModuleNotFoundError:
ie = InterpreterPoolExecutor = None
else:
InterpreterPoolExecutor = ie
if _have__interpreters and name == 'InterpreterPoolExecutor':
from .interpreter import InterpreterPoolExecutor as ie
InterpreterPoolExecutor = ie
return ie

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Raises :exc:`AttributeError` when accessing
``concurrent.futures.InterpreterPoolExecutor`` and ``_interpreter`` is
not available.
Loading