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[BaseException] = None,
failure_count: Optional[int] = None,
start_time: Optional[float] = None,
command_name: Optional[str] = None,
)
| 1143 | ) |
| 1144 | |
| 1145 | async def _reconnect( |
| 1146 | self, |
| 1147 | conn, |
| 1148 | error: Optional[BaseException] = None, |
| 1149 | failure_count: Optional[int] = None, |
| 1150 | start_time: Optional[float] = None, |
| 1151 | command_name: Optional[str] = None, |
| 1152 | ): |
| 1153 | """ |
| 1154 | The supported exceptions are already checked in the |
| 1155 | retry object so we don't need to do it here. |
| 1156 | |
| 1157 | In this error handler we are trying to reconnect to the server. |
| 1158 | """ |
| 1159 | if ( |
| 1160 | error |
| 1161 | and failure_count is not None |
| 1162 | and failure_count <= conn.retry.get_retries() |
| 1163 | ): |
| 1164 | if command_name: |
| 1165 | await record_operation_duration( |
| 1166 | command_name=command_name, |
| 1167 | duration_seconds=time.monotonic() - start_time, |
| 1168 | server_address=getattr(conn, "host", None), |
| 1169 | server_port=getattr(conn, "port", None), |
| 1170 | db_namespace=str(conn.db), |
| 1171 | error=error, |
| 1172 | retry_attempts=failure_count, |
| 1173 | ) |
| 1174 | await conn.disconnect(error=error, failure_count=failure_count) |
| 1175 | await conn.connect() |
| 1176 | |
| 1177 | async def _execute(self, conn, command, *args, **kwargs): |
| 1178 | """ |
no test coverage detected