Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add async redis client utils to prefect-redis #16417

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
missed one
  • Loading branch information
zzstoatzz committed Dec 17, 2024
commit 77e87de2a5f6de28eaf72e9f87d1e88eefe65b1e
6 changes: 3 additions & 3 deletions src/integrations/prefect-redis/prefect_redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class RedisSettings(PrefectBaseSettings):
Callable[..., Any],
tuple[Any, ...],
tuple[tuple[str, Any], ...],
asyncio.AbstractEventLoop | None,
Union[asyncio.AbstractEventLoop, None],
]

_client_cache: dict[CacheKey, Redis] = {}


def _running_loop() -> asyncio.AbstractEventLoop | None:
def _running_loop() -> Union[asyncio.AbstractEventLoop, None]:
try:
return asyncio.get_running_loop()
except RuntimeError as e:
Expand All @@ -62,7 +62,7 @@ def cached_fn(*args: Any, **kwargs: Any) -> Redis:

def close_all_cached_connections() -> None:
"""Close all cached Redis connections."""
loop: asyncio.AbstractEventLoop | None
loop: Union[asyncio.AbstractEventLoop, None]

for (_, _, _, loop), client in _client_cache.items():
if loop and loop.is_closed():
Expand Down
Loading