2
0
mirror of https://opendev.org/x/pyghmi synced 2025-08-24 12:00:21 +00:00

Provide a grace period for session validity

If a session has *just* expired, it may just be waiting for the
next timeout pass.  If it expired 15 seconds ago, however, it should
by all rights be beyond dead.

This matters as the calling code may be oblivious to the change of
session object under the covers if this is tripped.

Change-Id: I5be3bafb5932c287eb17c66217ba630746533310
This commit is contained in:
Jarrod Johnson
2018-07-16 11:18:38 -04:00
parent 33beac870d
commit 62211a05df

View File

@@ -406,7 +406,7 @@ class Session(object):
with util.protect(KEEPALIVE_SESSIONS):
sess = cls.keepalive_sessions.get(session, None)
if sess is not None and 'timeout' in sess:
if sess['timeout'] < _monotonic_time():
if sess['timeout'] < _monotonic_time() - 15:
# session would have timed out by now, don't use it
return False
return True