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

Method close

gunicorn/http2/async_connection.py:545–565  ·  view source on GitHub ↗

Close the connection gracefully with GOAWAY.

(self, error_code=0x0, last_stream_id=None)

Source from the content-addressed store, hash-verified

543 await self._send_pending_data()
544
545 async def close(self, error_code=0x0, last_stream_id=None):
546 """Close the connection gracefully with GOAWAY."""
547 if self._closed:
548 return
549
550 self._closed = True
551
552 if last_stream_id is None:
553 last_stream_id = max(self.streams.keys()) if self.streams else 0
554
555 try:
556 self.h2_conn.close_connection(error_code=error_code)
557 await self._send_pending_data()
558 except Exception:
559 pass
560
561 try:
562 self.writer.close()
563 await self.writer.wait_closed()
564 except Exception:
565 pass
566
567 async def _send_pending_data(self):
568 """Send any pending data from h2 to the socket."""

Callers 6

receive_dataMethod · 0.95
test_close_connectionMethod · 0.95
test_close_idempotentMethod · 0.95
send_responseMethod · 0.45
send_dataMethod · 0.45
send_trailersMethod · 0.45

Calls 3

_send_pending_dataMethod · 0.95
keysMethod · 0.45
wait_closedMethod · 0.45

Tested by 2

test_close_connectionMethod · 0.76
test_close_idempotentMethod · 0.76