redis/redis-py · error · RedisClusterException
method load_scripts() is not implemented
Error message
method load_scripts() is not implemented
What it means
Raised by AbstractStrategy.load_scripts() in redis/cluster.py:4122. In a standalone Redis client, pipelines call SCRIPT LOAD to pre-load Lua scripts so EVALSHA can be used; in Redis Cluster a script must be loaded on every primary, and this method is intentionally left unimplemented on the base strategy. The cluster pipeline handles script loading through a different code path (execute_command of EVAL/EVALSHA), so calling this method directly is a misuse of the API.
Solutions
- Remove the explicit load_scripts() call from your cluster pipeline code; let EVAL/EVALSHA handle script loading automatically through execute_command.
- If you need a script loaded on all nodes, execute SCRIPT LOAD manually against each primary via rc.cluster_execute_command('SCRIPT LOAD', script, target_nodes='primaries').
- Switch to a non-cluster Redis client if you genuinely need the standalone pipeline load_scripts() semantics.
Example fix
// before pipe = rc.pipeline() pipe.load_scripts() // after # no explicit load_scripts() needed; EVAL/EVALSHA loads lazily pipe = rc.pipeline()
Defensive patterns
Strategy: validation
Validate before calling
from redis.cluster import RedisCluster
is_cluster = isinstance(rc, RedisCluster)
if not is_cluster:
pipe.load_scripts() # safe only on standalone Type guard
def supports_load_scripts(client) -> bool:
from redis.cluster import RedisCluster
return not isinstance(client, RedisCluster) Try / catch
from redis.exceptions import RedisClusterException
try:
pipe.load_scripts()
except RedisClusterException:
pass # not supported on cluster pipelines Prevention
- Audit pipeline code when migrating standalone to cluster.
- Gate standalone-only optimizations behind a client-type check.
When it happens
Trigger: Calling the load_scripts() method directly on a ClusterPipeline instance or on an AbstractStrategy subclass that does not override it: e.g. pipe.load_scripts() where pipe = rc.pipeline() from a RedisCluster client.
Common situations: Code ported verbatim from a standalone redis.Redis pipeline to a redis.cluster.RedisCluster pipeline without removing the explicit SCRIPT LOAD warm-up step; test harnesses that call load_scripts() generically across client types.
Related errors
- method script_load_for_pipeline() is not implemented
- Cannot issue a WATCH after a MULTI
- method discard() is not supported outside of transactional…
- method eval() is not implemented
- method multi() is not supported outside of transactional…
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/feb1da68ea3962b9.
Report an issue: GitHub.
Appendix: source
Thrown at redis/cluster.py:4122
def send_cluster_commands(
self, stack, raise_on_error=True, allow_redirections=True
):
pass
@abstractmethod
def reset(self):
pass
def exists(self, *keys):
return self.execute_command("EXISTS", *keys)
def eval(self):
""" """
raise RedisClusterException("method eval() is not implemented")
def load_scripts(self):
""" """
raise RedisClusterException("method load_scripts() is not implemented")
def script_load_for_pipeline(self, *args, **kwargs):
""" """
raise RedisClusterException(
"method script_load_for_pipeline() is not implemented"
)
def annotate_exception(self, exception, number, command):
"""
Provides extra context to the exception prior to it being handled
"""
cmd = " ".join(map(safe_str, command))
msg = (
f"Command # {number} ({truncate_text(cmd)}) of pipeline "
f"caused error: {exception.args[0]}"
)
exception.args = (msg,) + exception.args[1:]
View on GitHub (pinned to 6a6b581b48)