Use eager start for august subscriber refreshes (#111581)

Since most of the time this call will be a noop since pubnub will be connected
we can avoid scheduling a task on the event loop every time it fires
pull/111574/head^2
J. Nick Koston 2024-02-26 18:13:33 -10:00 committed by GitHub
parent cfe478245f
commit 1e02260bbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -43,12 +43,17 @@ class AugustSubscriberMixin:
async def _async_refresh(self, time: datetime) -> None:
"""Refresh data."""
@callback
def _async_scheduled_refresh(self, now: datetime) -> None:
"""Call the refresh method."""
self._hass.async_create_task(self._async_refresh(now), eager_start=True)
@callback
def _async_setup_listeners(self) -> None:
"""Create interval and stop listeners."""
self._unsub_interval = async_track_time_interval(
self._hass,
self._async_refresh,
self._async_scheduled_refresh,
self._update_interval,
name="august refresh",
)