|
1 | 1 | from itertools import chain
|
2 | 2 | import copy
|
3 | 3 | import datetime
|
4 |
| -import hashlib |
5 | 4 | import re
|
6 | 5 | import threading
|
7 | 6 | import time
|
|
15 | 14 | ConnectionError,
|
16 | 15 | ExecAbortError,
|
17 | 16 | ModuleError,
|
18 |
| - NoScriptError, |
19 | 17 | PubSubError,
|
20 | 18 | RedisError,
|
21 | 19 | ResponseError,
|
@@ -1896,37 +1894,3 @@ def watch(self, *names):
|
1896 | 1894 | def unwatch(self):
|
1897 | 1895 | "Unwatches all previously specified keys"
|
1898 | 1896 | return self.watching and self.execute_command('UNWATCH') or True
|
1899 |
| - |
1900 |
| - |
1901 |
| -class Script: |
1902 |
| - "An executable Lua script object returned by ``register_script``" |
1903 |
| - |
1904 |
| - def __init__(self, registered_client, script): |
1905 |
| - self.registered_client = registered_client |
1906 |
| - self.script = script |
1907 |
| - # Precalculate and store the SHA1 hex digest of the script. |
1908 |
| - |
1909 |
| - if isinstance(script, str): |
1910 |
| - # We need the encoding from the client in order to generate an |
1911 |
| - # accurate byte representation of the script |
1912 |
| - encoder = registered_client.connection_pool.get_encoder() |
1913 |
| - script = encoder.encode(script) |
1914 |
| - self.sha = hashlib.sha1(script).hexdigest() |
1915 |
| - |
1916 |
| - def __call__(self, keys=[], args=[], client=None): |
1917 |
| - "Execute the script, passing any required ``args``" |
1918 |
| - if client is None: |
1919 |
| - client = self.registered_client |
1920 |
| - args = tuple(keys) + tuple(args) |
1921 |
| - # make sure the Redis server knows about the script |
1922 |
| - if isinstance(client, Pipeline): |
1923 |
| - # Make sure the pipeline can register the script before executing. |
1924 |
| - client.scripts.add(self) |
1925 |
| - try: |
1926 |
| - return client.evalsha(self.sha, len(keys), *args) |
1927 |
| - except NoScriptError: |
1928 |
| - # Maybe the client is pointed to a different server than the client |
1929 |
| - # that created this instance? |
1930 |
| - # Overwrite the sha just in case there was a discrepancy. |
1931 |
| - self.sha = client.script_load(self.script) |
1932 |
| - return client.evalsha(self.sha, len(keys), *args) |
0 commit comments