Fix flapping recorder tests (#116239)

This commit is contained in:
Erik Montnemery 2024-04-26 16:05:23 +02:00 committed by GitHub
parent c9301850be
commit aa65f21be7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

View file

@ -972,10 +972,11 @@ class HomeAssistant:
target = cast(Callable[[*_Ts], Coroutine[Any, Any, _R] | _R], target)
return self.async_run_hass_job(HassJob(target), *args)
def block_till_done(self) -> None:
def block_till_done(self, wait_background_tasks: bool = False) -> None:
"""Block until all pending work is done."""
asyncio.run_coroutine_threadsafe(
self.async_block_till_done(), self.loop
self.async_block_till_done(wait_background_tasks=wait_background_tasks),
self.loop,
).result()
async def async_block_till_done(self, wait_background_tasks: bool = False) -> None: