mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Migrate MQTT EnsureJobAfterCooldown to use eager start (#115977)
This commit is contained in:
parent
f2adae4524
commit
0ed56694b0
@ -41,6 +41,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
|||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util import dt as dt_util
|
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 homeassistant.util.logging import catch_log_exception
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -352,7 +353,7 @@ class EnsureJobAfterCooldown:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._async_cancel_timer()
|
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)
|
self._task.add_done_callback(self._async_task_done)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -1487,6 +1487,7 @@ async def test_mqtt_integration_discovery_subscribe_unsubscribe(
|
|||||||
await async_start(hass, "homeassistant", entry)
|
await async_start(hass, "homeassistant", entry)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
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 ("comp/discovery/#", 0) in help_all_subscribe_calls(mqtt_client_mock)
|
||||||
assert not mqtt_client_mock.unsubscribe.called
|
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 async_start(hass, "homeassistant", entry)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
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 ("comp/discovery/#", 0) in help_all_subscribe_calls(mqtt_client_mock)
|
||||||
assert not mqtt_client_mock.unsubscribe.called
|
assert not mqtt_client_mock.unsubscribe.called
|
||||||
|
Loading…
x
Reference in New Issue
Block a user