MCPcopy
hub / github.com/tornadoweb/tornado / future_set_result_unless_cancelled

Function future_set_result_unless_cancelled

tornado/concurrent.py:185–196  ·  view source on GitHub ↗

Set the given ``value`` as the `Future`'s result, if not cancelled. Avoids ``asyncio.InvalidStateError`` when calling ``set_result()`` on a cancelled `asyncio.Future`. .. versionadded:: 5.0

(
    future: "Union[futures.Future[_T], Future[_T]]", value: _T
)

Source from the content-addressed store, hash-verified

183
184
185def future_set_result_unless_cancelled(
186 future: "Union[futures.Future[_T], Future[_T]]", value: _T
187) -> None:
188 """Set the given ``value`` as the `Future`'s result, if not cancelled.
189
190 Avoids ``asyncio.InvalidStateError`` when calling ``set_result()`` on
191 a cancelled `asyncio.Future`.
192
193 .. versionadded:: 5.0
194 """
195 if not future.cancelled():
196 future.set_result(value)
197
198
199def future_set_exception_unless_cancelled(

Callers 15

handle_responseMethod · 0.90
_finish_readMethod · 0.90
_handle_writeMethod · 0.90
_handle_connectMethod · 0.90
_finish_ssl_connectMethod · 0.90
wrapperFunction · 0.90
multi_futureFunction · 0.90
callbackFunction · 0.90
sleepFunction · 0.90
runMethod · 0.90
put_nowaitMethod · 0.90
get_nowaitMethod · 0.90

Calls

no outgoing calls