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

Class Request

src/debugpy/common/messaging.py:612–749  ·  view source on GitHub ↗

Represents an incoming or an outgoing request. Incoming requests are represented directly by instances of this class. Outgoing requests are represented by instances of OutgoingRequest, which provides additional functionality to handle responses. For incoming requests, it is guaran

Source from the content-addressed store, hash-verified

610
611
612class Request(Message):
613 """Represents an incoming or an outgoing request.
614
615 Incoming requests are represented directly by instances of this class.
616
617 Outgoing requests are represented by instances of OutgoingRequest, which provides
618 additional functionality to handle responses.
619
620 For incoming requests, it is guaranteed that arguments is a MessageDict associated
621 with this Request, and so are all the nested dicts in it. If "arguments" was missing
622 or null in JSON, arguments is an empty dict.
623
624 To handle the request, JsonMessageChannel tries to find a handler for this request
625 in JsonMessageChannel.handlers. Given command="X", if handlers.X_request exists,
626 then it is the specific handler for this request. Otherwise, handlers.request must
627 exist, and it is the generic handler for this request. A missing handler is a fatal
628 error.
629
630 The handler is then invoked with the Request object as its sole argument.
631
632 If the handler itself invokes respond() on the Request at any point, then it must
633 not return any value.
634
635 Otherwise, if the handler returns NO_RESPONSE, no response to the request is sent.
636 It must be sent manually at some later point via respond().
637
638 Otherwise, a response to the request is sent with the returned value as the body.
639
640 To fail the request, the handler can return an instance of MessageHandlingError,
641 or respond() with one, or raise one such that it applies_to() the Request object
642 being handled.
643
644 Helper methods Message.isnt_valid() and Message.cant_handle() can be used to raise
645 the appropriate exception type that applies_to() the Request object.
646 """
647
648 def __init__(self, channel, seq, command, arguments, json=None):
649 super().__init__(channel, seq, json)
650
651 self.command = command
652
653 if isinstance(arguments, MessageDict) and hasattr(arguments, "associate_with"):
654 arguments.associate_with(self)
655 self.arguments = arguments
656
657 self.response = None
658 """Response to this request.
659
660 For incoming requests, it is set as soon as the request handler returns.
661
662 For outgoing requests, it is set as soon as the response is received, and
663 before self._handle_response is invoked.
664 """
665
666 def describe(self):
667 return f"#{self.seq} request {json.repr(self.command)} from {self.channel}"
668
669 @property

Callers 1

_parseMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…