Migrate MQTT EnsureJobAfterCooldown to use eager start (#115977)
parent
f2adae4524
commit
0ed56694b0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue