|
44 | 44 | KEEPALIVE_TASK_NAME = "ADT Pulse Keepalive Task"
|
45 | 45 | # backoff time before warning in wait_for_update()
|
46 | 46 | WARN_TRANSIENT_FAILURE_THRESHOLD = 2
|
| 47 | +FULL_LOGOUT_INTERVAL = 24 * 60 * 60 |
47 | 48 |
|
48 | 49 |
|
49 | 50 | class PyADTPulseAsync:
|
@@ -260,7 +261,7 @@ def should_relogin(relogin_interval: int) -> bool:
|
260 | 261 | > randint(int(0.75 * relogin_interval), relogin_interval)
|
261 | 262 | )
|
262 | 263 |
|
263 |
| - next_full_logout_time = time.time() + 24 * 60 * 60 |
| 264 | + next_full_logout_time = time.time() + FULL_LOGOUT_INTERVAL |
264 | 265 | response: str | None
|
265 | 266 | task_name: str = self._get_task_name(self._timeout_task, KEEPALIVE_TASK_NAME)
|
266 | 267 | LOG.debug("creating %s", task_name)
|
@@ -290,7 +291,7 @@ def should_relogin(relogin_interval: int) -> bool:
|
290 | 291 | )
|
291 | 292 | await self._sync_check_sleeping.wait()
|
292 | 293 | if msg == "full":
|
293 |
| - next_full_logout_time = time.time() + 24 * 60 * 60 |
| 294 | + next_full_logout_time = time.time() + FULL_LOGOUT_INTERVAL |
294 | 295 | await self.async_logout()
|
295 | 296 | else:
|
296 | 297 | await self._pulse_connection.quick_logout()
|
@@ -621,11 +622,11 @@ async def async_logout(self) -> None:
|
621 | 622 | if self._pulse_connection.login_in_progress:
|
622 | 623 | LOG.debug("Login in progress, returning")
|
623 | 624 | return
|
624 |
| - self._set_update_exception(PulseNotLoggedInError()) |
625 | 625 | LOG.info(
|
626 | 626 | "Logging %s out of ADT Pulse", self._authentication_properties.username
|
627 | 627 | )
|
628 | 628 | if asyncio.current_task() not in (self._sync_task, self._timeout_task):
|
| 629 | + self._set_update_exception(PulseNotLoggedInError()) |
629 | 630 | await self._cancel_task(self._timeout_task)
|
630 | 631 | await self._cancel_task(self._sync_task)
|
631 | 632 | await self._pulse_connection.async_do_logout_query(self.site.id)
|
|
0 commit comments