diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-04-09 10:33:28 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-04-09 10:33:28 -0700 |
commit | f49debc2cedb6fad04f81e79555e8b0ab467ab0f (patch) | |
tree | e555d9bdfddc708b21fe134740c58d5dae179118 /redis/client.py | |
parent | a89915fdf32381568b94b277224ded8fa25ee784 (diff) | |
download | redis-py-f49debc2cedb6fad04f81e79555e8b0ab467ab0f.tar.gz |
Make sure we know the SHA of scripts before pipeline execution. Fixes #459
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py index 78b3dbe..27162f6 100644 --- a/redis/client.py +++ b/redis/client.py @@ -2383,11 +2383,14 @@ class BasePipeline(object): scripts = list(self.scripts) immediate = self.immediate_execute_command shas = [s.sha for s in scripts] + # we can't use the normal script_* methods because they would just + # get buffered in the pipeline. exists = immediate('SCRIPT', 'EXISTS', *shas, **{'parse': 'EXISTS'}) if not all(exists): for s, exist in izip(scripts, exists): if not exist: - immediate('SCRIPT', 'LOAD', s.script, **{'parse': 'LOAD'}) + s.sha = immediate('SCRIPT', 'LOAD', s.script, + **{'parse': 'LOAD'}) def execute(self, raise_on_error=True): "Execute all the commands in the current pipeline" @@ -2439,6 +2442,12 @@ class BasePipeline(object): def script_load_for_pipeline(self, script): "Make sure scripts are loaded prior to pipeline execution" + # we need the sha now so that Script.__call__ can use it to run + # evalsha. + if not script.sha: + script.sha = self.immediate_execute_command('SCRIPT', 'LOAD', + script.script, + **{'parse': 'LOAD'}) self.scripts.add(script) |