Skip to content

Commit 7c5fd0a

Browse files
authored
Merge branch 'master' into ci-entraid-fix
2 parents f924ed6 + 577b4ac commit 7c5fd0a

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

redis/asyncio/sentinel.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ def __init__(
198198
sentinels,
199199
min_other_sentinels=0,
200200
sentinel_kwargs=None,
201+
force_master_ip=None,
201202
**connection_kwargs,
202203
):
203204
# if sentinel_kwargs isn't defined, use the socket_* options from
@@ -214,6 +215,7 @@ def __init__(
214215
]
215216
self.min_other_sentinels = min_other_sentinels
216217
self.connection_kwargs = connection_kwargs
218+
self._force_master_ip = force_master_ip
217219

218220
async def execute_command(self, *args, **kwargs):
219221
"""
@@ -277,7 +279,13 @@ async def discover_master(self, service_name: str):
277279
sentinel,
278280
self.sentinels[0],
279281
)
280-
return state["ip"], state["port"]
282+
283+
ip = (
284+
self._force_master_ip
285+
if self._force_master_ip is not None
286+
else state["ip"]
287+
)
288+
return ip, state["port"]
281289

282290
error_info = ""
283291
if len(collected_errors) > 0:

redis/commands/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import warnings
66
from typing import (
77
TYPE_CHECKING,
8+
Any,
89
AsyncIterator,
910
Awaitable,
1011
Callable,
@@ -6397,12 +6398,12 @@ def function_list(
63976398
return self.execute_command("FUNCTION LIST", *args)
63986399

63996400
def _fcall(
6400-
self, command: str, function, numkeys: int, *keys_and_args: Optional[List]
6401+
self, command: str, function, numkeys: int, *keys_and_args: Any
64016402
) -> Union[Awaitable[str], str]:
64026403
return self.execute_command(command, function, numkeys, *keys_and_args)
64036404

64046405
def fcall(
6405-
self, function, numkeys: int, *keys_and_args: Optional[List]
6406+
self, function, numkeys: int, *keys_and_args: Any
64066407
) -> Union[Awaitable[str], str]:
64076408
"""
64086409
Invoke a function.
@@ -6412,7 +6413,7 @@ def fcall(
64126413
return self._fcall("FCALL", function, numkeys, *keys_and_args)
64136414

64146415
def fcall_ro(
6415-
self, function, numkeys: int, *keys_and_args: Optional[List]
6416+
self, function, numkeys: int, *keys_and_args: Any
64166417
) -> Union[Awaitable[str], str]:
64176418
"""
64186419
This is a read-only variant of the FCALL command that cannot

tests/test_asyncio/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ async def sentinel_setup(local_cache, request):
129129
for ip, port in (endpoint.split(":") for endpoint in sentinel_ips.split(","))
130130
]
131131
kwargs = request.param.get("kwargs", {}) if hasattr(request, "param") else {}
132+
force_master_ip = request.param.get("force_master_ip", None)
132133
sentinel = Sentinel(
133134
sentinel_endpoints,
135+
force_master_ip=force_master_ip,
134136
socket_timeout=0.1,
135137
client_cache=local_cache,
136138
protocol=3,

0 commit comments

Comments
 (0)