Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to add serialized redis as master? #372

Open
BarryThrill opened this issue Apr 2, 2021 · 0 comments
Open

Is it possible to add serialized redis as master? #372

BarryThrill opened this issue Apr 2, 2021 · 0 comments
Assignees

Comments

@BarryThrill
Copy link

BarryThrill commented Apr 2, 2021

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 :'(

@brainix brainix self-assigned this Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants