Repository navigation
Description
Is your feature request related to a problem? Please describe.
Im currently using Serialized Redis as I use a orderedDict and much other with the package that has those features that I need. The problem is that I do not know how to use conn = serialized_redis.MsgpackSerializedRedis(host='localhost', port=6379, db=0) in the Redlock as masters
Describe the solution you'd like
For me as a heavy user in Serialized Redis, it would be very awesome to use Redlock together with it. That would help me to solve where I instead of needing connect two redis connection to one which saves the resources and also more correctly to do.
Additional context
I have created a small script together with the serialized redis:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import time
import serialized_redis
from pottery import Redlock
conn = serialized_redis.MsgpackSerializedRedis(host='localhost', port=6379, db=0)
lock = Redlock(key='basket_test', masters={conn}, auto_release_time=15 * 1000)
try:
lock.acquire()
test = bool(lock.locked())
print("Locked test ?", test)
time.sleep(2)
test1 = bool(lock.locked())
print("Locked test1 ?", test)
lock.release()
test3 = bool(lock.locked())
print("Locked test3 ?", test)
except Exception as err:
print("Unfortunately there is an error here!", err)which returns:
Locked test ? False
Locked test1 ? False
Unfortunately there is an error here! key='redlock:basket_test', masters=[MsgpackSerializedRedis<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>]
Another code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import time
import serialized_redis
from pottery import Redlock
from redis import Redis
conn = serialized_redis.MsgpackSerializedRedis(host='localhost', port=6379, db=0)
redis = Redis.from_url('redis://localhost:6379/0')
lock = Redlock(key='basket_test', masters={conn}, auto_release_time=15 * 1000)
try:
with lock:
print("We have locked it... I think... Let's see")
print("Locked?", bool(lock.locked()))
time.sleep(2)
print("After 'with lock', Are we released?")
print("Released?", bool(lock.locked()))
except Exception as err:
print("Unfortunately there is an error here!", err)
>>> We have locked it... I think... Let's see
>>> Locked? False
>>> Unfortunately there is an error here! key='redlock:basket_test', masters=[MsgpackSerializedRedis<ConnectionPool<Connection<host=localhost,port=6379,db=0>>>]
I assume it does it incorrectly together with serialized_redis :'(
Activity