__init__.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. BrokenExecutor,
  11. Future,
  12. Executor,
  13. wait,
  14. as_completed)
  15. __all__ = (
  16. 'FIRST_COMPLETED',
  17. 'FIRST_EXCEPTION',
  18. 'ALL_COMPLETED',
  19. 'CancelledError',
  20. 'TimeoutError',
  21. 'BrokenExecutor',
  22. 'Future',
  23. 'Executor',
  24. 'wait',
  25. 'as_completed',
  26. 'ProcessPoolExecutor',
  27. 'ThreadPoolExecutor',
  28. )
  29. def __dir__():
  30. return __all__ + ('__author__', '__doc__')
  31. def __getattr__(name):
  32. global ProcessPoolExecutor, ThreadPoolExecutor
  33. if name == 'ProcessPoolExecutor':
  34. from .process import ProcessPoolExecutor as pe
  35. ProcessPoolExecutor = pe
  36. return pe
  37. if name == 'ThreadPoolExecutor':
  38. from .thread import ThreadPoolExecutor as te
  39. ThreadPoolExecutor = te
  40. return te
  41. raise AttributeError(f"module {__name__} has no attribute {name}")