question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lock.release() always fails in python 3.6.6 (Redis-py 2.10.5)

See original GitHub issue
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=6, micro=6, releaselevel='final', serial=0)
>>> import redis
>>> redis.__version__
'2.10.5'
>>> redis_connection = redis.StrictRedis(host='redis', port=6379, decode_responses=True)
>>> lock = redis.lock.Lock(redis_connection, 'aa29f76d-f2be-4acb-abd8-7e74a336ceda')
>>> lock.acquire()
True
>>> lock.release()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/redis/lock.py", line 135, in release
    self.do_release(expected_token)
  File "/usr/local/lib/python3.6/dist-packages/redis/lock.py", line 146, in do_release
    self.redis.transaction(execute_release, name)
  File "/usr/local/lib/python3.6/dist-packages/redis/client.py", line 490, in transaction
    func_value = func(pipe)
  File "/usr/local/lib/python3.6/dist-packages/redis/lock.py", line 143, in execute_release
    raise LockError("Cannot release a lock that's no longer owned")
redis.exceptions.LockError: Cannot release a lock that's no longer owned
>>> 

Redis-py Version: 2.10.5 Python Version: 3.6.6

The functionality used to work in python 2.7, but now simply acquiring and releasing a lock fails. I tried in with block as well with same result.

Am I doing something wrong or is this a bug? Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
theodespcommented, Dec 3, 2018

@benileo I can replicate this issue on that version. The reason is a type mismatch when comparing the local token with the expected token here. For example:

lock_value
'532d532cf74b11e89bc0a45e60d2bdff'
expected_token
b'532d532cf74b11e89bc0a45e60d2bdff'

lock_value != expected_token
True

I suspect a newer version fixes this issue.

1reaction
benileocommented, Nov 30, 2018

I observe same behaviour in 2.10.6. I think an upgrade to 3.0+ is very likely 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lock.release() always fails in python 3.6.6 (Redis-py 2.10.5)
The functionality used to work in python 2.7, but now simply acquiring and releasing a lock fails. I tried in with block as...
Read more >
xadd not found with redis py 2.10.5 - Stack Overflow
You're using too old client, RedisPy 2.10.5 was released in 2015. XADD is a stream feature that has been released in Redis 5.0...
Read more >
redis-py-cluster Documentation
It has been found that the python module name that is used in this library (rediscluster) is already shared with a similar but...
Read more >
redis-py-cluster Documentation - Read the Docs
Since Python 3 changed to Unicode strings from Python 2's ASCII, the return type of most commands will be binary strings, unless the...
Read more >
redis - PyPI
redis-py. The Python interface to the Redis key-value store. CI docs MIT licensed pypi pre-release codecov. Installation | Usage | Advanced Topics | ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found