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