docs(redis): say why async paths cannot reuse redis_connect_func

The AUTH exchange it runs is the blocking client API, so on an async
connection send_command and read_response hand back coroutines nobody
awaits and the connect fails outright.
This commit is contained in:
mateo-berri 2026-08-20 15:46:03 -07:00
parent cba4fa403d
commit bfe54eb013

View file

@ -577,8 +577,10 @@ def _init_async_redis_sentinel(redis_kwargs) -> async_redis.Redis:
def _async_credential_provider(redis_connect_func: object | None) -> CredentialProvider | None:
"""Async redis-py never calls ``redis_connect_func``; it authenticates through a
``CredentialProvider``, which it consults per connection so the token refreshes."""
"""``redis_connect_func`` runs the AUTH exchange with the blocking client API, so on an
async connection its ``send_command``/``read_response`` calls return coroutines nobody
awaits and every connect fails. Async paths authenticate through a ``CredentialProvider``
instead, which redis-py consults per connection so the token stays fresh."""
gcp_service_account: Final = getattr(redis_connect_func, "_gcp_service_account", None)
if gcp_service_account is not None:
return GCPIAMCredentialProvider(gcp_service_account)