MCPcopy Create free account
hub / github.com/microsoft/debugpy / _handle

Method _handle

src/debugpy/common/messaging.py:697–749  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

695 channel._enqueue_handlers(message, message._handle)
696
697 def _handle(self):
698 channel = self.channel
699 handler = channel._get_handler_for("request", self.command)
700 try:
701 try:
702 result = handler(self)
703 except MessageHandlingError as exc:
704 if not exc.applies_to(self):
705 raise
706 result = exc
707 log.error(
708 "Handler {0}\ncouldn't handle {1}:\n{2}",
709 util.srcnameof(handler),
710 self.describe(),
711 str(exc),
712 )
713
714 if result is NO_RESPONSE:
715 assert self.response is None, (
716 "Handler {0} for {1} must not return NO_RESPONSE if it has already "
717 "invoked request.respond().".format(
718 util.srcnameof(handler), self.describe()
719 )
720 )
721 elif self.response is not None:
722 assert result is None or result is self.response.body, (
723 "Handler {0} for {1} must not return a response body if it has "
724 "already invoked request.respond().".format(
725 util.srcnameof(handler), self.describe()
726 )
727 )
728 else:
729 assert result is not None, (
730 "Handler {0} for {1} must either call request.respond() before it "
731 "returns, or return the response body, or return NO_RESPONSE.".format(
732 util.srcnameof(handler), self.describe()
733 )
734 )
735 try:
736 self.respond(result)
737 except NoMoreMessages:
738 log.warning(
739 "Channel was closed before the response from handler {0} to {1} could be sent",
740 util.srcnameof(handler),
741 self.describe(),
742 )
743
744 except Exception:
745 log.reraise_exception(
746 "Handler {0}\ncouldn't handle {1}:",
747 util.srcnameof(handler),
748 self.describe(),
749 )
750
751
752class OutgoingRequest(Request):

Callers

nothing calls this directly

Calls 5

describeMethod · 0.95
respondMethod · 0.95
_get_handler_forMethod · 0.80
applies_toMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected