MCPcopy
hub / github.com/redis/redis-py / _reconnect

Method _reconnect

redis/asyncio/client.py:1145–1175  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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 """

Callers 1

failure_callbackMethod · 0.95

Calls 5

get_retriesMethod · 0.80
monotonicMethod · 0.80
disconnectMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected