When I was using lock.release
from fakeredis
lib, I got below exception:
File "/usr/local/lib/python3.6/site-packages/redis/lock.py", line 111, in acquire
if self.do_acquire(token):
File "/usr/local/lib/python3.6/site-packages/redis/lock.py", line 258, in do_acquire
client=self.redis))
File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 2950, in __call__
return client.evalsha(self.sha, len(keys), *args)
File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 2079, in evalsha
return self.execute_command('EVALSHA', sha, numkeys, *keys_and_args)
File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 667, in execute_command
connection.send_command(*args)
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 610, in send_command
self.send_packed_command(self.pack_command(*args))
File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 590, in send_packed_command
self._sock.sendall(item)
File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 808, in sendall
self._parser.send(data)
File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 725, in _parse_commands
self._process_command(fields)
File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 827, in _process_command
result = self._run_command(func, sig, fields[1:], False)
File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 741, in _run_command
result = func(*args)
File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 2439, in evalsha
return self.eval(script, numkeys, *keys_and_args)
File "/usr/local/lib/python3.6/site-packages/fakeredis/_server.py", line 2386, in eval
from lupa import LuaRuntime, LuaError, as_attrgetter
No module named 'lupa'
I didn't find a similar question (So far) so I just wanted to share the solution for those people who will face this exception in the future
As mentioned in the doc,
Although fakeredis is pure Python, you will need
lupa
if you want to run Lua scripts (this includes features like redis.lock.Lock, which are implemented in Lua). If you installfakeredis
withpip install fakeredis[lua]
it will be automatically installed.
So:
pip install fakeredis[lua]
If you got this error:
zsh: no matches found: fakeredis[lua]
Use this to solve this:
zsh uses square brackets for globbing / pattern matching: stackoverflow.com/a/30539963/8808983.
So you need to do:
pip install 'fakeredis[lua]'