__init__.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. 'BrokenExecutor',
  23. 'Future',
  24. 'Executor',
  25. 'wait',
  26. 'as_completed',
  27. 'ProcessPoolExecutor',
  28. 'ThreadPoolExecutor',
  29. )
  30. def __dir__():
  31. return __all__ + ('__author__', '__doc__')
  32. def __getattr__(name):
  33. global ProcessPoolExecutor, ThreadPoolExecutor
  34. if name == 'ProcessPoolExecutor':
  35. from .process import ProcessPoolExecutor as pe
  36. ProcessPoolExecutor = pe
  37. return pe
  38. if name == 'ThreadPoolExecutor':
  39. from .thread import ThreadPoolExecutor as te
  40. ThreadPoolExecutor = te
  41. return te
  42. raise AttributeError(f"module {__name__!r} has no attribute {name!r}")