MCPcopy Index your code
hub / github.com/python/cpython / set_result

Method set_result

Lib/concurrent/futures/_base.py:531–544  ·  view source on GitHub ↗

Sets the return value of work associated with the future. Should only be used by Executor implementations and unit tests.

(self, result)

Source from the content-addressed store, hash-verified

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.

Callers 2

runMethod · 0.45
process_result_itemMethod · 0.45

Calls 5

_invoke_callbacksMethod · 0.95
InvalidStateErrorClass · 0.70
formatMethod · 0.45
add_resultMethod · 0.45
notify_allMethod · 0.45

Tested by

no test coverage detected