The supported exceptions are already checked in the retry object so we don't need to do it here. In this error handler we are trying to reconnect to the server.
(
self,
conn,
error: Optional[Exception] = None,
failure_count: Optional[int] = None,
start_time: Optional[float] = None,
command_name: Optional[str] = None,
)
| 1118 | ttl -= 1 |
| 1119 | |
| 1120 | def _reconnect( |
| 1121 | self, |
| 1122 | conn, |
| 1123 | error: Optional[Exception] = None, |
| 1124 | failure_count: Optional[int] = None, |
| 1125 | start_time: Optional[float] = None, |
| 1126 | command_name: Optional[str] = None, |
| 1127 | ) -> None: |
| 1128 | """ |
| 1129 | The supported exceptions are already checked in the |
| 1130 | retry object so we don't need to do it here. |
| 1131 | |
| 1132 | In this error handler we are trying to reconnect to the server. |
| 1133 | """ |
| 1134 | if error and failure_count <= conn.retry.get_retries(): |
| 1135 | if command_name: |
| 1136 | record_operation_duration( |
| 1137 | command_name=command_name, |
| 1138 | duration_seconds=time.monotonic() - start_time, |
| 1139 | server_address=getattr(conn, "host", None), |
| 1140 | server_port=getattr(conn, "port", None), |
| 1141 | db_namespace=str(conn.db), |
| 1142 | error=error, |
| 1143 | retry_attempts=failure_count, |
| 1144 | ) |
| 1145 | conn.disconnect() |
| 1146 | conn.connect() |
| 1147 | |
| 1148 | def _execute(self, conn, command, *args, **kwargs): |
| 1149 | """ |
no test coverage detected