MCPcopy Create free account
hub / github.com/python-websockets/websockets / parse_close

Function parse_close

src/websockets/legacy/framing.py:203–216  ·  view source on GitHub ↗

Parse the payload from a close frame. Returns: Close code and reason. Raises: ProtocolError: If data is ill-formed. UnicodeDecodeError: If the reason isn't valid UTF-8.

(data: bytes)

Source from the content-addressed store, hash-verified

201
202
203def parse_close(data: bytes) -> tuple[int, str]:
204 """
205 Parse the payload from a close frame.
206
207 Returns:
208 Close code and reason.
209
210 Raises:
211 ProtocolError: If data is ill-formed.
212 UnicodeDecodeError: If the reason isn't valid UTF-8.
213
214 """
215 close = Close.parse(data)
216 return close.code, close.reason
217
218
219def serialize_close(code: int, reason: str) -> bytes:

Callers 3

assertCloseDataMethod · 0.85

Calls 1

parseMethod · 0.45

Tested by 3

assertCloseDataMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…