| 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 |
|
| 13 |
from concurrent.futures import Future as _BaseFuture |
| 14 |
from concurrent.futures._base import LOGGER |
| 15 |
|
| 16 |
|
| 17 |
# To make loky._base.Future instances awaitable by concurrent.futures.wait, |
| 18 |
# derive our custom Future class from _BaseFuture. _invoke_callback is the only |
| 19 |
# modification made to this class in loky. |
| 20 |
# TODO investigate why using `concurrent.futures.Future` directly does not |
| 21 |
# always work in our test suite. |
| 22 |
class Future(_BaseFuture): |
| 23 |
def _invoke_callbacks(self): |
| 24 |
for callback in self._done_callbacks: |
| 25 |
try: |
| 26 |
callback(self) |
| 27 |
except BaseException: |
| 28 |
LOGGER.exception(f"exception calling callback for {self!r}") |