Close the connection before retrying. The supported exceptions are already checked in the retry object so we don't need to do it here. After we disconnect the connection, it will try to reconnect and do a health check as part of the send_command logic(on co
(
self,
conn,
error: Optional[Exception] = None,
failure_count: Optional[int] = None,
start_time: Optional[float] = None,
command_name: Optional[str] = None,
)
| 764 | return self.parse_response(conn, command_name, **options) |
| 765 | |
| 766 | def _close_connection( |
| 767 | self, |
| 768 | conn, |
| 769 | error: Optional[Exception] = None, |
| 770 | failure_count: Optional[int] = None, |
| 771 | start_time: Optional[float] = None, |
| 772 | command_name: Optional[str] = None, |
| 773 | ) -> None: |
| 774 | """ |
| 775 | Close the connection before retrying. |
| 776 | |
| 777 | The supported exceptions are already checked in the |
| 778 | retry object so we don't need to do it here. |
| 779 | |
| 780 | After we disconnect the connection, it will try to reconnect and |
| 781 | do a health check as part of the send_command logic(on connection level). |
| 782 | """ |
| 783 | if error and failure_count <= conn.retry.get_retries(): |
| 784 | record_operation_duration( |
| 785 | command_name=command_name, |
| 786 | duration_seconds=time.monotonic() - start_time, |
| 787 | server_address=getattr(conn, "host", None), |
| 788 | server_port=getattr(conn, "port", None), |
| 789 | db_namespace=str(conn.db), |
| 790 | error=error, |
| 791 | retry_attempts=failure_count, |
| 792 | ) |
| 793 | |
| 794 | conn.disconnect() |
| 795 | |
| 796 | # COMMAND EXECUTION AND PROTOCOL PARSING |
| 797 | def execute_command(self, *args, **options): |
no test coverage detected