Deprecate calling async_listen and async_listen_once with run_immediately (#115169)

This commit is contained in:
J. Nick Koston 2024-04-08 10:07:54 -10:00 committed by GitHub
parent 5ef42078a3
commit ca5ed274cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 126 additions and 243 deletions

View file

@ -299,7 +299,6 @@ async def async_test_home_assistant(
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP,
hass.config_entries._async_shutdown,
run_immediately=True,
)
# Load the registries
@ -358,9 +357,7 @@ async def async_test_home_assistant(
await asyncio.sleep(0) # Give aiohttp one loop iteration to close
INSTANCES.remove(hass)
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_CLOSE, clear_instance, run_immediately=True
)
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, clear_instance)
yield hass
@ -918,9 +915,7 @@ class MockEntityPlatform(entity_platform.EntityPlatform):
def _async_on_stop(_: Event) -> None:
self.async_shutdown()
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP, _async_on_stop, run_immediately=True
)
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_on_stop)
class MockToggleEntity(entity.ToggleEntity):
@ -1493,7 +1488,7 @@ def async_capture_events(hass: HomeAssistant, event_name: str) -> list[Event]:
def capture_events(event: Event) -> None:
events.append(event)
hass.bus.async_listen(event_name, capture_events, run_immediately=True)
hass.bus.async_listen(event_name, capture_events)
return events