4 ms·
I wrote a very similar, Redis-based lock in Python a while ago, here it is: https://gist.github.com/adewes/6103220 https://gist.github.com/adewes/6103220 It u
by ThePhysicist 12y ago
I wrote a very similar, Redis-based lock in Python a while ago, here it is:
https://gist.github.com/adewes/6103220 https://gist.github.com/adewes/6103220
It uses Redis pipelines and watchers to make sure that no race conditions between two processes requiring the same lock occur, and uses "expire" keys to avoid deadlocks.
- thezilch 12y agoYou should just use redis-py's Lock (https://github.com/andymccurdy/redis-py/blob/master/redis/client.py#L2576 https://github.com/andymccurdy/redis-py/blob/master/redis/cl...)
- klibertp 12y agoI prefer Lua-scripting based approach: https://github.com/bbangert/retools/blob/master/retools/lock.py https://github.com/bbangert/retools/blob/master/retools/lock..., but I had to implement something similar to your code to support older Redis versions.