Skip to content

Commit

Permalink
Supports Redis client args
Browse files Browse the repository at this point in the history
  • Loading branch information
EltonCN committed Dec 2, 2024
1 parent 7e0a9b5 commit d5c4da5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cst_python/memory_storage/memory_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
logger.setLevel(logging.DEBUG)

class MemoryStorageCodelet(Codelet):
def __init__(self, mind:Mind, node_name:Optional[str]=None, mind_name:Optional[str]=None, request_timeout:float=500e-3) -> None:
def __init__(self, mind:Mind,
node_name:Optional[str]=None, mind_name:Optional[str]=None,
request_timeout:float=500e-3, **redis_args) -> None:
super().__init__()

self._mind = mind
Expand All @@ -28,8 +30,11 @@ def __init__(self, mind:Mind, node_name:Optional[str]=None, mind_name:Optional[s
self._mind_name = cast(str, mind_name)

self._memories : weakref.WeakValueDictionary[str, Memory] = weakref.WeakValueDictionary()

if "decode_responses" in redis_args:
del redis_args["decode_responses"]

self._client = redis.Redis(decode_responses=True)
self._client = redis.Redis(decode_responses=True, **redis_args)
self._pubsub = self._client.pubsub()
self._pubsub_thread : redis.client.PubSubWorkerThread = self._pubsub.run_in_thread(daemon=True)

Expand Down

0 comments on commit d5c4da5

Please sign in to comment.