• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2009 Brian Quinlan. All Rights Reserved.
2# Licensed to PSF under a Contributor Agreement.
3
4"""Execute computations asynchronously using threads or processes."""
5
6__author__ = 'Brian Quinlan (brian@sweetapp.com)'
7
8from concurrent.futures._base import (FIRST_COMPLETED,
9                                      FIRST_EXCEPTION,
10                                      ALL_COMPLETED,
11                                      CancelledError,
12                                      TimeoutError,
13                                      BrokenExecutor,
14                                      Future,
15                                      Executor,
16                                      wait,
17                                      as_completed)
18
19__all__ = (
20    'FIRST_COMPLETED',
21    'FIRST_EXCEPTION',
22    'ALL_COMPLETED',
23    'CancelledError',
24    'TimeoutError',
25    'BrokenExecutor',
26    'Future',
27    'Executor',
28    'wait',
29    'as_completed',
30    'ProcessPoolExecutor',
31    'ThreadPoolExecutor',
32)
33
34
35def __dir__():
36    return __all__ + ('__author__', '__doc__')
37
38
39def __getattr__(name):
40    global ProcessPoolExecutor, ThreadPoolExecutor
41
42    if name == 'ProcessPoolExecutor':
43        from .process import ProcessPoolExecutor as pe
44        ProcessPoolExecutor = pe
45        return pe
46
47    if name == 'ThreadPoolExecutor':
48        from .thread import ThreadPoolExecutor as te
49        ThreadPoolExecutor = te
50        return te
51
52    raise AttributeError(f"module {__name__} has no attribute {name}")
53