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

Method close

gunicorn/http2/connection.py:610–630  ·  view source on GitHub ↗

Close the connection gracefully with GOAWAY. Args: error_code: HTTP/2 error code (default: NO_ERROR) last_stream_id: Last processed stream ID (default: highest)

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

Source from the content-addressed store, hash-verified

608 self._send_pending_data()
609
610 def close(self, error_code=0x0, last_stream_id=None):
611 """Close the connection gracefully with GOAWAY.
612
613 Args:
614 error_code: HTTP/2 error code (default: NO_ERROR)
615 last_stream_id: Last processed stream ID (default: highest)
616 """
617 if self._closed:
618 return
619
620 self._closed = True
621
622 if last_stream_id is None:
623 # Use highest stream ID we've seen
624 last_stream_id = max(self.streams.keys()) if self.streams else 0
625
626 try:
627 self.h2_conn.close_connection(error_code=error_code)
628 self._send_pending_data()
629 except Exception:
630 pass # Best effort
631
632 def _send_pending_data(self):
633 """Send any pending data from h2 to the socket."""

Callers 9

receive_dataMethod · 0.95
_handle_data_receivedMethod · 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 2

_send_pending_dataMethod · 0.95
keysMethod · 0.45

Tested by 3

test_close_connectionMethod · 0.76
test_close_idempotentMethod · 0.76