Skip to content

Commit 40e88fa

Browse files
committed
don't set not logged in exception when sync check task logs out
1 parent bba47a9 commit 40e88fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pyadtpulse/pyadtpulse_async.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +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
4748

4849

4950
class PyADTPulseAsync:
@@ -260,7 +261,7 @@ def should_relogin(relogin_interval: int) -> bool:
260261
> randint(int(0.75 * relogin_interval), relogin_interval)
261262
)
262263

263-
next_full_logout_time = time.time() + 24 * 60 * 60
264+
next_full_logout_time = time.time() + FULL_LOGOUT_INTERVAL
264265
response: str | None
265266
task_name: str = self._get_task_name(self._timeout_task, KEEPALIVE_TASK_NAME)
266267
LOG.debug("creating %s", task_name)
@@ -290,7 +291,7 @@ def should_relogin(relogin_interval: int) -> bool:
290291
)
291292
await self._sync_check_sleeping.wait()
292293
if msg == "full":
293-
next_full_logout_time = time.time() + 24 * 60 * 60
294+
next_full_logout_time = time.time() + FULL_LOGOUT_INTERVAL
294295
await self.async_logout()
295296
else:
296297
await self._pulse_connection.quick_logout()
@@ -621,11 +622,11 @@ async def async_logout(self) -> None:
621622
if self._pulse_connection.login_in_progress:
622623
LOG.debug("Login in progress, returning")
623624
return
624-
self._set_update_exception(PulseNotLoggedInError())
625625
LOG.info(
626626
"Logging %s out of ADT Pulse", self._authentication_properties.username
627627
)
628628
if asyncio.current_task() not in (self._sync_task, self._timeout_task):
629+
self._set_update_exception(PulseNotLoggedInError())
629630
await self._cancel_task(self._timeout_task)
630631
await self._cancel_task(self._sync_task)
631632
await self._pulse_connection.async_do_logout_query(self.site.id)

0 commit comments

Comments
 (0)