8000 Is it possible to add serialized redis as master? · Issue #372 · brainix/pottery · GitHub
[go: up one dir, main page]

Skip to content

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

Open

Description

@BarryThrill

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

  1. self-assigned this
    on Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0