summaryrefslogtreecommitdiffstats
path: root/Lib/concurrent
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2018-01-20 00:54:42 (GMT)
committerGitHub <noreply@github.com>2018-01-20 00:54:42 (GMT)
commit6690bb9f17d34eb3dec0aca8919d8d27d6c3c452 (patch)
treefb237c82733daa1c4536ad8a93253f413adbeca3 /Lib/concurrent
parent338cd83c5dceaed785f5bf613e2122f871908e2a (diff)
downloadcpython-6690bb9f17d34eb3dec0aca8919d8d27d6c3c452.zip
cpython-6690bb9f17d34eb3dec0aca8919d8d27d6c3c452.tar.gz
cpython-6690bb9f17d34eb3dec0aca8919d8d27d6c3c452.tar.bz2
bpo-32596: Lazy import concurrent.futures.process and thread (GH-5241)
Diffstat (limited to 'Lib/concurrent')
-rw-r--r--Lib/concurrent/futures/__init__.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/Lib/concurrent/futures/__init__.py b/Lib/concurrent/futures/__init__.py
index ba8de16..72aca81 100644
--- a/Lib/concurrent/futures/__init__.py
+++ b/Lib/concurrent/futures/__init__.py
@@ -15,5 +15,36 @@ from concurrent.futures._base import (FIRST_COMPLETED,
Executor,
wait,
as_completed)
-from concurrent.futures.process import ProcessPoolExecutor
-from concurrent.futures.thread import ThreadPoolExecutor
+
+__all__ = (
+ 'FIRST_COMPLETED',
+ 'FIRST_EXCEPTION',
+ 'ALL_COMPLETED',
+ 'CancelledError',
+ 'TimeoutError',
+ 'BrokenExecutor',
+ 'Future',
+ 'Executor',
+ 'wait',
+ 'as_completed',
+ 'ProcessPoolExecutor',
+ 'ThreadPoolExecutor',
+)
+
+
+def __dir__():
+ return __all__ + ('__author__', '__doc__')
+
+
+def __getattr__(name):
+ global ProcessPoolExecutor, ThreadPoolExecutor
+
+ if name == 'ProcessPoolExecutor':
+ from .process import ProcessPoolExecutor
+ return ProcessPoolExecutor
+
+ if name == 'ThreadPoolExecutor':
+ from .thread import ThreadPoolExecutor
+ return ThreadPoolExecutor
+
+ raise AttributeError(f"module {__name__} has no attribute {name}")