Fix lingering timer in hassio (#91702)

This commit is contained in:
epenet 2023-04-20 20:56:45 +02:00 committed by GitHub
parent cf4c491e79
commit 821b9bdb5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import asyncio
from contextlib import suppress
from datetime import timedelta
from datetime import datetime, timedelta
import logging
import os
from typing import Any, NamedTuple
@ -29,6 +29,7 @@ from homeassistant.const import (
)
from homeassistant.core import (
DOMAIN as HASS_DOMAIN,
HassJob,
HomeAssistant,
ServiceCall,
callback,
@ -492,7 +493,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
DOMAIN, service, async_service_handler, schema=settings.schema
)
async def update_info_data(now):
async def update_info_data(_: datetime | None = None) -> None:
"""Update last available supervisor information."""
try:
@ -516,11 +517,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
_LOGGER.warning("Can't read Supervisor data: %s", err)
async_track_point_in_utc_time(
hass, update_info_data, utcnow() + HASSIO_UPDATE_INTERVAL
hass,
HassJob(update_info_data, cancel_on_shutdown=True),
utcnow() + HASSIO_UPDATE_INTERVAL,
)
# Fetch data
await update_info_data(None)
await update_info_data()
async def async_handle_core_service(call: ServiceCall) -> None:
"""Service handler for handling core services."""