Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError.
(self, result)
| 259 | # So-called internal methods (note: no set_running_or_notify_cancel()). |
| 260 | |
| 261 | def set_result(self, result): |
| 262 | """Mark the future done and set its result. |
| 263 | |
| 264 | If the future is already done when this method is called, raises |
| 265 | InvalidStateError. |
| 266 | """ |
| 267 | if self._state != _PENDING: |
| 268 | raise exceptions.InvalidStateError(f'{self._state}: {self!r}') |
| 269 | self._result = result |
| 270 | self._state = _FINISHED |
| 271 | self.__schedule_callbacks() |
| 272 | |
| 273 | def set_exception(self, exception): |
| 274 | """Mark the future done and set an exception. |