MCPcopy Create free account
hub / github.com/adafruit/Adafruit_CircuitPython_HTTPServer / close

Method close

adafruit_httpserver/response.py:987–1004  ·  view source on GitHub ↗

Close the connection. **Always call this method when you are done sending events.**

(self, code: int = None, reason: str = None)

Source from the content-addressed store, hash-verified

985 return bytes(payload)
986
987 def close(self, code: int = None, reason: str = None):
988 """
989 Close the connection.
990
991 **Always call this method when you are done sending events.**
992 """
993 if self.closed:
994 return
995
996 self._reset_fragmented_message()
997
998 payload = self._prepare_close_payload(code, reason)
999 try:
1000 self.send_message(payload, Websocket.CLOSE, fail_silently=True)
1001 except (BrokenPipeError, OSError):
1002 pass
1003 self._close_connection()
1004 self.closed = True

Callers 6

connect_clientFunction · 0.95
_handle_control_frameMethod · 0.95
receiveMethod · 0.95
_close_connectionMethod · 0.45
stopMethod · 0.45
pollMethod · 0.45

Calls 4

send_messageMethod · 0.95
_close_connectionMethod · 0.80

Tested by

no test coverage detected