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

Method _run_callback

python/python3/tornado/ioloop.py:732–760  ·  view source on GitHub ↗

Runs a callback with error handling. .. versionchanged:: 6.0 CancelledErrors are no longer logged.

(self, callback: Callable[[], Any])

Source from the content-addressed store, hash-verified

730 self._executor = executor
731
732 def _run_callback(self, callback: Callable[[], Any]) -> None:
733 """Runs a callback with error handling.
734
735 .. versionchanged:: 6.0
736
737 CancelledErrors are no longer logged.
738 """
739 try:
740 ret = callback()
741 if ret is not None:
742 from tornado import gen
743
744 # Functions that return Futures typically swallow all
745 # exceptions and store them in the Future. If a Future
746 # makes it out to the IOLoop, ensure its exception (if any)
747 # gets logged too.
748 try:
749 ret = gen.convert_yielded(ret)
750 except gen.BadYieldError:
751 # It's not unusual for add_callback to be used with
752 # methods returning a non-None and non-yieldable
753 # result, which should just be ignored.
754 pass
755 else:
756 self.add_future(ret, self._discard_future_result)
757 except asyncio.CancelledError:
758 pass
759 except Exception:
760 app_log.error("Exception in callback %r", callback, exc_info=True)
761
762 def _discard_future_result(self, future: Future) -> None:
763 """Avoid unhandled-exception warnings from spawned coroutines."""

Callers 1

add_futureMethod · 0.95

Calls 3

add_futureMethod · 0.95
errorMethod · 0.80
callbackFunction · 0.70

Tested by

no test coverage detected