Fix task leak on config entry unload/retry (#96981)

Since the task was added to self._tasks without a `task.add_done_callback(self._tasks.remove)`
each unload/retry would leak a new set of tasks
This commit is contained in:
J. Nick Koston 2023-07-20 20:00:07 -05:00 committed by GitHub
parent 99def97ed9
commit 9fba6870fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -687,7 +687,7 @@ class ConfigEntry:
if self._on_unload is not None:
while self._on_unload:
if job := self._on_unload.pop()():
self._tasks.add(hass.async_create_task(job))
self.async_create_task(hass, job)
if not self._tasks and not self._background_tasks:
return