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

Method _send_message

src/debugpy/common/messaging.py:1200–1224  ·  view source on GitHub ↗

Sends a new message to the other party. Generates a new sequence number for the message, and provides it to the caller before the message is sent, using the context manager protocol:: with send_message(...) as seq: # The message hasn't been sent yet.

(self, message)

Source from the content-addressed store, hash-verified

1198
1199 @contextlib.contextmanager
1200 def _send_message(self, message):
1201 """Sends a new message to the other party.
1202
1203 Generates a new sequence number for the message, and provides it to the
1204 caller before the message is sent, using the context manager protocol::
1205
1206 with send_message(...) as seq:
1207 # The message hasn't been sent yet.
1208 ...
1209 # Now the message has been sent.
1210
1211 Safe to call concurrently for the same channel from different threads.
1212 """
1213
1214 assert "seq" not in message
1215 with self:
1216 seq = next(self._seq_iter)
1217
1218 message = MessageDict(None, message)
1219 message["seq"] = seq
1220 self._prettify(message)
1221
1222 with self:
1223 yield seq
1224 self.stream.write_json(message)
1225
1226 def send_request(self, command, arguments=None, on_before_send=None):
1227 """Sends a new request, and returns the OutgoingRequest object for it.

Callers 3

send_requestMethod · 0.95
send_eventMethod · 0.95
respondMethod · 0.80

Calls 3

_prettifyMethod · 0.95
MessageDictClass · 0.85
write_jsonMethod · 0.45

Tested by

no test coverage detected