Close the connection gracefully with GOAWAY.
(self, error_code=0x0, last_stream_id=None)
| 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.""" |