Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion clients/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies = [
"orjson>=3.10.10",
"protobuf>=5.28.3",
"redis>=3.4.1",
"redis-py-cluster>=2.1.0",
"zstandard>=0.18.0",
]

Expand All @@ -34,6 +33,11 @@ dev = [
"types-protobuf>=5.27.0.20240626,<6.0.0",
]
[project.optional-dependencies]
# redis<4 does not bundle cluster support; pull in redis-py-cluster (EOL) for it.
# Not needed on redis>=4.1, which provides redis.RedisCluster natively.
cluster = [
"redis-py-cluster>=2.1.0",
]
examples = [
"click>=8.3",
"setuptools>=80.0",
Expand Down
14 changes: 9 additions & 5 deletions clients/python/src/taskbroker_client/scheduler/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

from collections.abc import Mapping
from datetime import UTC, datetime
from typing import Protocol
from typing import TYPE_CHECKING, Protocol

from redis.client import StrictRedis
from rediscluster import RedisCluster

if TYPE_CHECKING:
try:
# redis>=4.1 ships cluster support natively
from redis import RedisCluster
except ImportError: # pragma: no cover - redis<4 fallback via the `cluster` extra
from rediscluster import RedisCluster

from taskbroker_client.metrics import MetricsBackend

Expand Down Expand Up @@ -105,9 +111,7 @@ class RunStorage(RunStorageProtocol):
Redis backed scheduler storage
"""

def __init__(
self, metrics: MetricsBackend, redis: RedisCluster[str] | StrictRedis[str]
) -> None:
def __init__(self, metrics: MetricsBackend, redis: RedisCluster | StrictRedis) -> None:
self._redis = redis
self._metrics = metrics

Expand Down
Loading