Skip to content

Commit 2673d9a

Browse files
committed
change full logout to approximately every 6 hours randomized
1 parent 40e88fa commit 2673d9a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pyadtpulse/pyadtpulse_async.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
KEEPALIVE_TASK_NAME = "ADT Pulse Keepalive Task"
4545
# backoff time before warning in wait_for_update()
4646
WARN_TRANSIENT_FAILURE_THRESHOLD = 2
47-
FULL_LOGOUT_INTERVAL = 24 * 60 * 60
47+
FULL_LOGOUT_INTERVAL = 6 * 60 * 60
4848

4949

5050
class PyADTPulseAsync:
@@ -261,7 +261,9 @@ def should_relogin(relogin_interval: int) -> bool:
261261
> randint(int(0.75 * relogin_interval), relogin_interval)
262262
)
263263

264-
next_full_logout_time = time.time() + FULL_LOGOUT_INTERVAL
264+
next_full_logout_time = time.time() + randint(
265+
int(0.75 * FULL_LOGOUT_INTERVAL), FULL_LOGOUT_INTERVAL
266+
)
265267
response: str | None
266268
task_name: str = self._get_task_name(self._timeout_task, KEEPALIVE_TASK_NAME)
267269
LOG.debug("creating %s", task_name)
@@ -291,7 +293,9 @@ def should_relogin(relogin_interval: int) -> bool:
291293
)
292294
await self._sync_check_sleeping.wait()
293295
if msg == "full":
294-
next_full_logout_time = time.time() + FULL_LOGOUT_INTERVAL
296+
next_full_logout_time = time.time() + randint(
297+
int(0.75 * FULL_LOGOUT_INTERVAL), FULL_LOGOUT_INTERVAL
298+
)
295299
await self.async_logout()
296300
else:
297301
await self._pulse_connection.quick_logout()

0 commit comments

Comments
 (0)