MCPcopy
hub / github.com/encode/uvicorn / connection_lost

Method connection_lost

uvicorn/protocols/websockets/wsproto_impl.py:130–142  ·  view source on GitHub ↗
(self, exc: Exception | None)

Source from the content-addressed store, hash-verified

128 self.logger.log(TRACE_LOG_LEVEL, "%sWebSocket connection made", prefix)
129
130 def connection_lost(self, exc: Exception | None) -> None:
131 self.stop_keepalive()
132 code = 1005 if self.handshake_complete else 1006
133 self.queue.put_nowait({"type": "websocket.disconnect", "code": code})
134 self.connections.remove(self)
135
136 if self.logger.level <= TRACE_LOG_LEVEL:
137 prefix = "%s:%d - " % self.client if self.client else ""
138 self.logger.log(TRACE_LOG_LEVEL, "%sWebSocket connection lost", prefix)
139
140 self.handshake_complete = True
141 if exc is None:
142 self.transport.close()
143
144 def eof_received(self) -> None:
145 pass

Callers

nothing calls this directly

Calls 2

stop_keepaliveMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected