Migrate MQTT EnsureJobAfterCooldown to use eager start (#115977)

pull/116006/head
J. Nick Koston 2024-04-22 20:09:45 +02:00 committed by GitHub
parent f2adae4524
commit 0ed56694b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -41,6 +41,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util
from homeassistant.util.async_ import create_eager_task
from homeassistant.util.logging import catch_log_exception
from .const import (
@ -352,7 +353,7 @@ class EnsureJobAfterCooldown:
return
self._async_cancel_timer()
self._task = asyncio.create_task(self._async_job())
self._task = create_eager_task(self._async_job())
self._task.add_done_callback(self._async_task_done)
@callback

View File

@ -1487,6 +1487,7 @@ async def test_mqtt_integration_discovery_subscribe_unsubscribe(
await async_start(hass, "homeassistant", entry)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done()
assert ("comp/discovery/#", 0) in help_all_subscribe_calls(mqtt_client_mock)
assert not mqtt_client_mock.unsubscribe.called
@ -1537,6 +1538,7 @@ async def test_mqtt_discovery_unsubscribe_once(
await async_start(hass, "homeassistant", entry)
await hass.async_block_till_done()
await hass.async_block_till_done()
await hass.async_block_till_done()
assert ("comp/discovery/#", 0) in help_all_subscribe_calls(mqtt_client_mock)
assert not mqtt_client_mock.unsubscribe.called