Skip to content

Commit c8e78dd

Browse files
fix: only configure redis once
1 parent 5a31a01 commit c8e78dd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

reflex/state.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,6 +3231,15 @@ async def get_redis(self) -> GlideClient:
32313231
return self.redis
32323232
redis = await prerequisites.get_redis()
32333233
assert redis is not None
3234+
try:
3235+
_ = await redis.config_set(
3236+
{"notify-keyspace-events": self._redis_notify_keyspace_events},
3237+
)
3238+
# TODO: adjust exception for glide
3239+
except ResponseError:
3240+
# Some redis servers only allow out-of-band configuration, so ignore errors here.
3241+
if not environment.REFLEX_IGNORE_REDIS_CONFIG_ERROR.get():
3242+
raise
32343243
self.redis = redis
32353244
return redis
32363245

@@ -3525,15 +3534,6 @@ async def get_pubsub(self, lock_key: bytes) -> GlideClient:
35253534
)
35263535
assert config is not None
35273536
pubsub = await GlideClient.create(config)
3528-
try:
3529-
_ = await pubsub.config_set(
3530-
{"notify-keyspace-events": self._redis_notify_keyspace_events},
3531-
)
3532-
# TODO: adjust exception for glide
3533-
except ResponseError:
3534-
# Some redis servers only allow out-of-band configuration, so ignore errors here.
3535-
if not environment.REFLEX_IGNORE_REDIS_CONFIG_ERROR.get():
3536-
raise
35373537
self._pubsub_clients[lock_key] = pubsub
35383538
return pubsub
35393539

0 commit comments

Comments
 (0)