diff --git a/supervisor/api/backups.py b/supervisor/api/backups.py index 0a5ca5aecb9..b37671bd9e3 100644 --- a/supervisor/api/backups.py +++ b/supervisor/api/backups.py @@ -296,13 +296,18 @@ async def release_on_freeze(new_state: CoreState): BusEvent.SUPERVISOR_STATE_CHANGE, release_on_freeze ) try: - await asyncio.wait( + event_task = self.sys_create_task(event.wait()) + _, pending = await asyncio.wait( ( backup_task, - self.sys_create_task(event.wait()), + event_task, ), return_when=asyncio.FIRST_COMPLETED, ) + # It seems backup returned early (error or something), make sure to cancel + # the event task to avoid "Task was destroyed but it is pending!" errors. + if event_task in pending: + event_task.cancel() return (backup_task, job.uuid) finally: self.sys_bus.remove_listener(listener)