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

Method connection_lost

uvicorn/protocols/http/h11_impl.py:106–129  ·  view source on GitHub ↗
(self, exc: Exception | None)

Source from the content-addressed store, hash-verified

104 self.logger.log(TRACE_LOG_LEVEL, "%sHTTP connection made", prefix)
105
106 def connection_lost(self, exc: Exception | None) -> None:
107 self.connections.discard(self)
108
109 if self.logger.level <= TRACE_LOG_LEVEL:
110 prefix = "%s:%d - " % self.client if self.client else ""
111 self.logger.log(TRACE_LOG_LEVEL, "%sHTTP connection lost", prefix)
112
113 if self.cycle and not self.cycle.response_complete:
114 self.cycle.disconnected = True
115 if self.conn.our_state != h11.ERROR:
116 event = h11.ConnectionClosed()
117 try:
118 self.conn.send(event)
119 except h11.LocalProtocolError:
120 # Premature client disconnect
121 pass
122
123 if self.cycle is not None:
124 self.cycle.message_event.set()
125 if self.flow is not None:
126 self.flow.resume_writing()
127 if exc is None:
128 self.transport.close()
129 self._unset_keepalive_if_required()
130
131 def eof_received(self) -> None:
132 pass

Callers 1

test_early_disconnectFunction · 0.45

Calls 4

sendMethod · 0.45
resume_writingMethod · 0.45
closeMethod · 0.45

Tested by 1

test_early_disconnectFunction · 0.36