redis/redis-py · error · RedisClusterException
method script_load_for_pipeline() is not implemented
Error message
method script_load_for_pipeline() is not implemented
What it means
Raised by AbstractStrategy.script_load_for_pipeline() in redis/cluster.py:4126. This standalone-pipeline helper loads a Lua script and rewrites pipeline EVAL calls to EVALSHA for wire efficiency; it has no cluster implementation because scripts must be sharded across nodes and the cluster pipeline does not rewrite commands that way. Calling it directly on a cluster pipeline is unsupported.
Solutions
- Drop the script_load_for_pipeline() call; the cluster pipeline routes EVAL/EVALSHA per-slot automatically.
- Pre-load the script on all primaries manually with rc.cluster_execute_command('SCRIPT LOAD', script, target_nodes='primaries') if you want EVALSHA availability.
- Use a non-cluster client if the standalone optimization is required.
Example fix
// before pipe = rc.pipeline() pipe.script_load_for_pipeline(script) // after pipe = rc.pipeline() pipe.eval(script, numkeys, *keys) # cluster handles routing
Defensive patterns
Strategy: validation
Validate before calling
from redis.cluster import RedisCluster
if not isinstance(rc, RedisCluster):
pipe.script_load_for_pipeline(script) Type guard
def supports_script_load_for_pipeline(client) -> bool:
from redis.cluster import RedisCluster
return not isinstance(client, RedisCluster) Try / catch
from redis.exceptions import RedisClusterException
try:
pipe.script_load_for_pipeline(script)
except RedisClusterException:
pass Prevention
- Do not call standalone pipeline helpers on cluster pipelines.
- Let EVAL/EVALSHA handle script loading in cluster mode.
When it happens
Trigger: Invoking pipe.script_load_for_pipeline(script) (or rc.script_load_for_pipeline(...)) on a RedisCluster or ClusterPipeline object, typically copied from standalone redis.Redis pipeline code.
Common situations: Migrating a standalone Redis pipeline optimization pattern to cluster mode; generic pipeline wrapper code that calls script_load_for_pipeline on every client type.
Related errors
- method load_scripts() 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/5b61482f4f23bff1.
Report an issue: GitHub.
Appendix: source
Thrown at redis/cluster.py:4126
@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:]
class PipelineStrategy(AbstractStrategy):
def __init__(self, pipe: ClusterPipeline):
super().__init__(pipe)View on GitHub (pinned to 6a6b581b48)