MCPcopy
hub / github.com/benoitc/gunicorn / _send_close

Method _send_close

gunicorn/asgi/websocket.py:423–437  ·  view source on GitHub ↗

Send a close frame.

(self, code, reason="")

Source from the content-addressed store, hash-verified

421 self.transport.write(bytes(frame))
422
423 async def _send_close(self, code, reason=""):
424 """Send a close frame."""
425 if self._close_sent:
426 return # Already sent
427
428 payload = struct.pack("!H", code)
429 if reason:
430 payload += reason.encode("utf-8")[:123] # Max 125 bytes total
431 await self._send_frame(OPCODE_CLOSE, payload)
432 self._close_sent = True
433
434 # If we already received a close, handshake is complete
435 if self._close_received:
436 self.closed = True
437 self._close_event.set()

Callers 4

runMethod · 0.95
_sendMethod · 0.95
_read_frameMethod · 0.95
_handle_closeMethod · 0.95

Calls 3

_send_frameMethod · 0.95
encodeMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected