Sets the return value of work associated with the future. Should only be used by Executor implementations and unit tests.
(self, result)
| 529 | raise RuntimeError('Future in unexpected state') |
| 530 | |
| 531 | def set_result(self, result): |
| 532 | """Sets the return value of work associated with the future. |
| 533 | |
| 534 | Should only be used by Executor implementations and unit tests. |
| 535 | """ |
| 536 | with self._condition: |
| 537 | if self._state in {CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED}: |
| 538 | raise InvalidStateError('{}: {!r}'.format(self._state, self)) |
| 539 | self._result = result |
| 540 | self._state = FINISHED |
| 541 | for waiter in self._waiters: |
| 542 | waiter.add_result(self) |
| 543 | self._condition.notify_all() |
| 544 | self._invoke_callbacks() |
| 545 | |
| 546 | def set_exception(self, exception): |
| 547 | """Sets the result of the future as being the given exception. |
no test coverage detected