__init__.py 1.5 KB

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