MCPcopy Create free account
hub / github.com/EasyIME/PIME / future_set_exception_unless_cancelled

Function future_set_exception_unless_cancelled

python/python3/tornado/concurrent.py:189–208  ·  view source on GitHub ↗

Set the given ``exc`` as the `Future`'s exception. If the Future is already canceled, logs the exception instead. If this logging is not desired, the caller should explicitly check the state of the Future and call ``Future.set_exception`` instead of this wrapper. Avoids ``async

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

Source from the content-addressed store, hash-verified

187
188
189def future_set_exception_unless_cancelled(
190 future: "Union[futures.Future[_T], Future[_T]]", exc: BaseException
191) -> None:
192 """Set the given ``exc`` as the `Future`'s exception.
193
194 If the Future is already canceled, logs the exception instead. If
195 this logging is not desired, the caller should explicitly check
196 the state of the Future and call ``Future.set_exception`` instead of
197 this wrapper.
198
199 Avoids ``asyncio.InvalidStateError`` when calling ``set_exception()`` on
200 a cancelled `asyncio.Future`.
201
202 .. versionadded:: 6.0
203
204 """
205 if not future.cancelled():
206 future.set_exception(exc)
207 else:
208 app_log.error("Exception after Future was cancelled", exc_info=exc)
209
210
211def future_set_exc_info(

Callers 3

handle_responseMethod · 0.90
callbackMethod · 0.90
future_set_exc_infoFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected