Skip to content

Commit

Permalink
Make system update run coroutines in order (and not simultaneously) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya authored Oct 8, 2021
1 parent 029ea5e commit 918d3eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions simplipy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(
self.request = backoff.on_exception(
backoff.expo,
ClientResponseError,
jitter=backoff.random_jitter,
logger=LOGGER,
max_tries=request_retries,
on_backoff=self._async_handle_on_backoff,
Expand Down
9 changes: 3 additions & 6 deletions simplipy/system/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Define V2 and V3 SimpliSafe systems."""
from __future__ import annotations

import asyncio
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
Expand Down Expand Up @@ -388,14 +387,12 @@ async def async_update(
:param cached: Whether to used cached data.
:type cached: ``bool``
"""
update_tasks = []
if include_subscription:
update_tasks.append(self._async_update_subscription_data())
await self._async_update_subscription_data()
if include_settings:
update_tasks.append(self._async_update_settings_data(cached))
await self._async_update_settings_data(cached)
if include_devices:
update_tasks.append(self._async_update_device_data(cached))
await asyncio.gather(*update_tasks)
await self._async_update_device_data(cached)

# Create notifications:
self._notifications = [
Expand Down

0 comments on commit 918d3eb

Please sign in to comment.