_base.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. ###############################################################################
  2. # Modification of concurrent.futures.Future
  3. #
  4. # author: Thomas Moreau and Olivier Grisel
  5. #
  6. # adapted from concurrent/futures/_base.py (17/02/2017)
  7. # * Do not use yield from
  8. # * Use old super syntax
  9. #
  10. # Copyright 2009 Brian Quinlan. All Rights Reserved.
  11. # Licensed to PSF under a Contributor Agreement.
  12. from concurrent.futures import Future as _BaseFuture
  13. from concurrent.futures._base import LOGGER
  14. # To make loky._base.Future instances awaitable by concurrent.futures.wait,
  15. # derive our custom Future class from _BaseFuture. _invoke_callback is the only
  16. # modification made to this class in loky.
  17. # TODO investigate why using `concurrent.futures.Future` directly does not
  18. # always work in our test suite.
  19. class Future(_BaseFuture):
  20. def _invoke_callbacks(self):
  21. for callback in self._done_callbacks:
  22. try:
  23. callback(self)
  24. except BaseException:
  25. LOGGER.exception(f"exception calling callback for {self!r}")