MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / _read_line

Method _read_line

examples/MCP Client/client.py:72–81  ·  view source on GitHub ↗

Read one newline-delimited JSON line, preserving leftover data

(self)

Source from the content-addressed store, hash-verified

70 return response
71
72 def _read_line(self):
73 """Read one newline-delimited JSON line, preserving leftover data"""
74 while b"\n" not in self._buffer:
75 chunk = self.sock.recv(4096)
76 if not chunk:
77 raise ConnectionError("Connection closed by server")
78 self._buffer += chunk
79
80 line, self._buffer = self._buffer.split(b"\n", 1)
81 return json.loads(line.decode("utf-8"))
82
83 def _read_response(self, request_id):
84 """Read lines until we get the JSON-RPC response matching request_id.

Callers 1

_read_responseMethod · 0.95

Calls 1

recvMethod · 0.80

Tested by

no test coverage detected