锁不能使用redis-py - 未知命令' EVALSHA'

时间:2014-09-19 07:29:58

标签: python redis locking redis-py

以下内容在redis中创建,获取和释放锁:

import redis

redis_url = 'redis://127.0.0.1:6379/'
redis_conn = redis.from_url(redis_url)

l = redis_conn.lock('lock-test')
l.acquire()
l.release()

如何引发acquire()以下错误?

Traceback (most recent call last):
  File "C:/dev/myproj/test.py", line 11, in <module>
    l.acquire()
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\lock.py", line 111, in acquire
    if self.do_acquire(token):
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\lock.py", line 258, in do_acquire
    client=self.redis))
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\client.py", line 2646, in __call__
    return client.evalsha(self.sha, len(keys), *args)
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\client.py", line 1911, in evalsha
    return self.execute_command('EVALSHA', sha, numkeys, *keys_and_args)
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\client.py", line 565, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\client.py", line 577, in parse_response
    response = connection.read_response()
  File "C:\dev\myproj\venv_myproj\lib\site-packages\redis\connection.py", line 574, in read_response
    raise response
redis.exceptions.ResponseError: unknown command 'EVALSHA'

我的设置:python 2.7.8,redis 2.4.5 64bit,win8

1 个答案:

答案 0 :(得分:1)

升级到最新的redis为我解决了这个问题 我最终使用VS13

this repo构建版本2.8.16