Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll supervisor job state when creating or restoring a backup #136891

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions homeassistant/components/hassio/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ def on_job_progress(data: Mapping[str, Any]) -> None:
backup_id = data.get("reference")
backup_complete.set()

unsub = self._async_listen_job_events(backup.job_id, on_job_progress)
try:
unsub = self._async_listen_job_events(backup.job_id, on_job_progress)
await self._get_job_state(backup.job_id, on_job_progress)
await backup_complete.wait()
finally:
unsub()
Expand Down Expand Up @@ -506,12 +507,13 @@ async def async_restore_backup(

@callback
def on_job_progress(data: Mapping[str, Any]) -> None:
"""Handle backup progress."""
"""Handle backup restore progress."""
if data.get("done") is True:
restore_complete.set()

unsub = self._async_listen_job_events(job.job_id, on_job_progress)
try:
unsub = self._async_listen_job_events(job.job_id, on_job_progress)
await self._get_job_state(job.job_id, on_job_progress)
await restore_complete.wait()
finally:
unsub()
Expand Down
Loading