mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 01:11:51 -04:00
async_listen and async_listen_once now errors if used with run_immediately (#182763)
This commit is contained in:
@@ -1728,8 +1728,9 @@ class EventBus:
|
||||
|
||||
frame.report_usage(
|
||||
"calls `async_listen` with run_immediately",
|
||||
core_behavior=frame.ReportBehavior.LOG,
|
||||
breaks_in_ha_version="2025.5",
|
||||
core_behavior=frame.ReportBehavior.ERROR,
|
||||
core_integration_behavior=frame.ReportBehavior.ERROR,
|
||||
custom_integration_behavior=frame.ReportBehavior.ERROR,
|
||||
)
|
||||
|
||||
if event_filter is not None and not is_callback_check_partial(event_filter):
|
||||
@@ -1798,8 +1799,9 @@ class EventBus:
|
||||
|
||||
frame.report_usage(
|
||||
"calls `async_listen_once` with run_immediately",
|
||||
core_behavior=frame.ReportBehavior.LOG,
|
||||
breaks_in_ha_version="2025.5",
|
||||
core_behavior=frame.ReportBehavior.ERROR,
|
||||
core_integration_behavior=frame.ReportBehavior.ERROR,
|
||||
custom_integration_behavior=frame.ReportBehavior.ERROR,
|
||||
)
|
||||
|
||||
one_time_listener: _OneTimeListener[_DataT] = _OneTimeListener(
|
||||
|
||||
+5
-5
@@ -3529,11 +3529,11 @@ async def test_async_listen_with_run_immediately_deprecated(
|
||||
pass
|
||||
|
||||
func = getattr(hass.bus, method)
|
||||
func(EVENT_HOMEASSISTANT_START, _test, run_immediately=run_immediately)
|
||||
assert (
|
||||
f"Detected code that calls `{method}` with run_immediately. "
|
||||
"This will stop working in Home Assistant 2025.5"
|
||||
) in caplog.text
|
||||
with pytest.raises(
|
||||
RuntimeError,
|
||||
match=f"Detected code that calls `{method}` with run_immediately. Please report this issue",
|
||||
):
|
||||
func(EVENT_HOMEASSISTANT_START, _test, run_immediately=run_immediately)
|
||||
|
||||
|
||||
async def test_async_fire_thread_safety(hass: HomeAssistant) -> None:
|
||||
|
||||
Reference in New Issue
Block a user