From 18bd5bc87a10180818acba931a1cd5e5225ccc08 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Mon, 15 Jun 2026 14:14:48 +0200 Subject: [PATCH] trying to make redis expire more backwards compatible as each beamline has different version of redis --- src/aare/daq/config.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/aare/daq/config.py b/src/aare/daq/config.py index 52a2cf2d..4ef95a19 100644 --- a/src/aare/daq/config.py +++ b/src/aare/daq/config.py @@ -342,8 +342,18 @@ class BeamlineConfig: raise Exception( "There is no active session with given id. Try again later." ) + # if active == session: + # self.__client.expire(f"{self.__bl}:active_session", expiry_sec, gt=True) + if active == session: - self.__client.expire(f"{self.__bl}:active_session", expiry_sec, gt=True) + key = f"{self.__bl}:active_session" + current_ttl = self.__client.ttl(key) + + # Redis compatibility: + # some Redis servers do not support EXPIRE with GT option. + # Emulate "extend only if greater" manually while holding the lock. + if current_ttl is None or current_ttl < 0 or current_ttl < expiry_sec: + self.__client.expire(key, expiry_sec) else: raise Exception( "There is already active session with different id. Try again later."