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."