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

Method handle_connection

gunicorn/dirty/worker.py:288–313  ·  view source on GitHub ↗

Handle a connection from the arbiter. Each connection can send multiple requests.

(self, reader, writer)

Source from the content-addressed store, hash-verified

286 await asyncio.sleep(self.cfg.dirty_timeout / 2.0)
287
288 async def handle_connection(self, reader, writer):
289 """
290 Handle a connection from the arbiter.
291
292 Each connection can send multiple requests.
293 """
294 self.log.debug("New connection from arbiter")
295
296 try:
297 while self.alive:
298 try:
299 message = await DirtyProtocol.read_message_async(reader)
300 except asyncio.IncompleteReadError:
301 # Connection closed
302 break
303
304 # Handle the request - pass writer for streaming support
305 await self.handle_request(message, writer)
306 except Exception as e:
307 self.log.error("Connection error: %s", e)
308 finally:
309 writer.close()
310 try:
311 await writer.wait_closed()
312 except Exception:
313 pass
314
315 async def handle_request(self, message, writer):
316 """

Callers

nothing calls this directly

Calls 6

handle_requestMethod · 0.95
debugMethod · 0.45
read_message_asyncMethod · 0.45
errorMethod · 0.45
closeMethod · 0.45
wait_closedMethod · 0.45

Tested by

no test coverage detected