Return the result of the call that the future represents. Args: timeout: The number of seconds to wait for the result if the future isn't done. If None, then there is no limit on the wait time. Returns: The result of the call that the future
(self, timeout=None)
| 420 | LOGGER.exception('exception calling callback for %r', self) |
| 421 | |
| 422 | def result(self, timeout=None): |
| 423 | """Return the result of the call that the future represents. |
| 424 | |
| 425 | Args: |
| 426 | timeout: The number of seconds to wait for the result if the future |
| 427 | isn't done. If None, then there is no limit on the wait time. |
| 428 | |
| 429 | Returns: |
| 430 | The result of the call that the future represents. |
| 431 | |
| 432 | Raises: |
| 433 | CancelledError: If the future was cancelled. |
| 434 | TimeoutError: If the future didn't finish executing before the given |
| 435 | timeout. |
| 436 | Exception: If the call raised then that exception will be raised. |
| 437 | """ |
| 438 | try: |
| 439 | with self._condition: |
| 440 | if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: |
| 441 | raise CancelledError() |
| 442 | elif self._state == FINISHED: |
| 443 | return self.__get_result() |
| 444 | |
| 445 | self._condition.wait(timeout) |
| 446 | |
| 447 | if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: |
| 448 | raise CancelledError() |
| 449 | elif self._state == FINISHED: |
| 450 | return self.__get_result() |
| 451 | else: |
| 452 | raise TimeoutError() |
| 453 | finally: |
| 454 | # Break a reference cycle with the exception in self._exception |
| 455 | self = None |
| 456 | |
| 457 | def exception(self, timeout=None): |
| 458 | """Return the exception raised by the call that the future represents. |
no test coverage detected