Skip to content

Commit 62bbcc1

Browse files
authored
Merge branch 'master' into ps_add_return_type_hints_to_redis_modules
2 parents 7e7a233 + e13c42b commit 62bbcc1

File tree

10 files changed

+234
-118
lines changed

10 files changed

+234
-118
lines changed

.github/workflows/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
max-parallel: 15
7575
fail-fast: false
7676
matrix:
77-
redis-version: ['8.0-RC2-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.7', '6.2.17']
77+
redis-version: ['8.0.1-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.7', '6.2.17']
7878
python-version: ['3.8', '3.13']
7979
parser-backend: ['plain']
8080
event-loop: ['asyncio']

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
7171
* Close SSL sockets if the connection attempt fails, or if validations fail. (#3317)
7272
* Eliminate mutable default arguments in the `redis.commands.core.Script` class. (#3332)
73+
* Allow newer versions of PyJWT as dependency. (#3630)
7374

7475
* 4.1.3 (Feb 8, 2022)
7576
* Fix flushdb and flushall (#1926)
@@ -1146,3 +1147,4 @@ incompatible in code using*SCAN commands loops such as
11461147
* Implemented STRLEN
11471148
* Implemented PERSIST
11481149
* Implemented SETRANGE
1150+
* Changed type annotation of the `num` parameter in `zrange` from `int` to `Optional[int]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ocsp = [
4141
"requests>=2.31.0",
4242
]
4343
jwt = [
44-
"PyJWT~=2.9.0",
44+
"PyJWT>=2.9.0",
4545
]
4646

4747
[project.urls]

redis/asyncio/cluster.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,9 @@ async def initialize(self) -> None:
13131313
startup_nodes_reachable = False
13141314
fully_covered = False
13151315
exception = None
1316-
for startup_node in self.startup_nodes.values():
1316+
# Convert to tuple to prevent RuntimeError if self.startup_nodes
1317+
# is modified during iteration
1318+
for startup_node in tuple(self.startup_nodes.values()):
13171319
try:
13181320
# Make sure cluster mode is enabled on this node
13191321
try:

redis/backoff.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ def __init__(self, backoff: float) -> None:
3131
"""`backoff`: backoff time in seconds"""
3232
self._backoff = backoff
3333

34+
def __hash__(self) -> int:
35+
return hash((self._backoff,))
36+
37+
def __eq__(self, other) -> bool:
38+
if not isinstance(other, ConstantBackoff):
39+
return NotImplemented
40+
41+
return self._backoff == other._backoff
42+
3443
def compute(self, failures: int) -> float:
3544
return self._backoff
3645

@@ -53,6 +62,15 @@ def __init__(self, cap: float = DEFAULT_CAP, base: float = DEFAULT_BASE):
5362
self._cap = cap
5463
self._base = base
5564

65+
def __hash__(self) -> int:
66+
return hash((self._base, self._cap))
67+
68+
def __eq__(self, other) -> bool:
69+
if not isinstance(other, ExponentialBackoff):
70+
return NotImplemented
71+
72+
return self._base == other._base and self._cap == other._cap
73+
5674
def compute(self, failures: int) -> float:
5775
return min(self._cap, self._base * 2**failures)
5876

@@ -68,6 +86,15 @@ def __init__(self, cap: float = DEFAULT_CAP, base: float = DEFAULT_BASE) -> None
6886
self._cap = cap
6987
self._base = base
7088

89+
def __hash__(self) -> int:
90+
return hash((self._base, self._cap))
91+
92+
def __eq__(self, other) -> bool:
93+
if not isinstance(other, FullJitterBackoff):
94+
return NotImplemented
95+
96+
return self._base == other._base and self._cap == other._cap
97+
7198
def compute(self, failures: int) -> float:
7299
return random.uniform(0, min(self._cap, self._base * 2**failures))
73100

@@ -83,6 +110,15 @@ def __init__(self, cap: float = DEFAULT_CAP, base: float = DEFAULT_BASE) -> None
83110
self._cap = cap
84111
self._base = base
85112

113+
def __hash__(self) -> int:
114+
return hash((self._base, self._cap))
115+
116+
def __eq__(self, other) -> bool:
117+
if not isinstance(other, EqualJitterBackoff):
118+
return NotImplemented
119+
120+
return self._base == other._base and self._cap == other._cap
121+
86122
def compute(self, failures: int) -> float:
87123
temp = min(self._cap, self._base * 2**failures) / 2
88124
return temp + random.uniform(0, temp)
@@ -100,6 +136,15 @@ def __init__(self, cap: float = DEFAULT_CAP, base: float = DEFAULT_BASE) -> None
100136
self._base = base
101137
self._previous_backoff = 0
102138

139+
def __hash__(self) -> int:
140+
return hash((self._base, self._cap))
141+
142+
def __eq__(self, other) -> bool:
143+
if not isinstance(other, DecorrelatedJitterBackoff):
144+
return NotImplemented
145+
146+
return self._base == other._base and self._cap == other._cap
147+
103148
def reset(self) -> None:
104149
self._previous_backoff = 0
105150

@@ -121,6 +166,15 @@ def __init__(self, cap: float = DEFAULT_CAP, base: float = DEFAULT_BASE) -> None
121166
self._cap = cap
122167
self._base = base
123168

169+
def __hash__(self) -> int:
170+
return hash((self._base, self._cap))
171+
172+
def __eq__(self, other) -> bool:
173+
if not isinstance(other, EqualJitterBackoff):
174+
return NotImplemented
175+
176+
return self._base == other._base and self._cap == other._cap
177+
124178
def compute(self, failures: int) -> float:
125179
return min(self._cap, random.random() * self._base * 2**failures)
126180

redis/cluster.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,9 @@ def initialize(self):
16741674
fully_covered = False
16751675
kwargs = self.connection_kwargs
16761676
exception = None
1677-
for startup_node in self.startup_nodes.values():
1677+
# Convert to tuple to prevent RuntimeError if self.startup_nodes
1678+
# is modified during iteration
1679+
for startup_node in tuple(self.startup_nodes.values()):
16781680
try:
16791681
if startup_node.redis_connection:
16801682
r = startup_node.redis_connection
@@ -2122,7 +2124,7 @@ def __init__(
21222124
else:
21232125
self.retry = Retry(
21242126
backoff=ExponentialWithJitterBackoff(base=1, cap=10),
2125-
retries=self.cluster_error_retry_attempts,
2127+
retries=cluster_error_retry_attempts,
21262128
)
21272129

21282130
self.encoder = Encoder(

0 commit comments

Comments
 (0)