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

Method _run_callback

python/python3/tornado/websocket.py:626–645  ·  view source on GitHub ↗

Runs the given callback with exception handling. If the callback is a coroutine, returns its Future. On error, aborts the websocket connection and returns None.

(
        self, callback: Callable, *args: Any, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

624 self.server_terminated = False
625
626 def _run_callback(
627 self, callback: Callable, *args: Any, **kwargs: Any
628 ) -> "Optional[Future[Any]]":
629 """Runs the given callback with exception handling.
630
631 If the callback is a coroutine, returns its Future. On error, aborts the
632 websocket connection and returns None.
633 """
634 try:
635 result = callback(*args, **kwargs)
636 except Exception:
637 self.handler.log_exception(*sys.exc_info())
638 self._abort()
639 return None
640 else:
641 if result is not None:
642 result = gen.convert_yielded(result)
643 assert self.stream is not None
644 self.stream.io_loop.add_future(result, lambda f: f.result())
645 return result
646
647 def on_connection_close(self) -> None:
648 self._abort()

Callers 1

_handle_messageMethod · 0.45

Calls 5

_abortMethod · 0.95
add_futureMethod · 0.80
resultMethod · 0.80
callbackFunction · 0.70
log_exceptionMethod · 0.45

Tested by

no test coverage detected