Skip to content

Fix navigation cleanup under all exit paths#41

Draft
pascalzauberzeug wants to merge 2 commits into
mainfrom
fix_automator_stop
Draft

Fix navigation cleanup under all exit paths#41
pascalzauberzeug wants to merge 2 commits into
mainfrom
fix_automator_stop

Conversation

@pascalzauberzeug
Copy link
Copy Markdown
Contributor

@pascalzauberzeug pascalzauberzeug commented May 5, 2026

Motivation

With rosys#403, the automator now closes the wrapped coroutine on stop, raising GeneratorExit inside start(). Awaiting self.finish() from the finally block was not safe under.

Implementation

  • Replace the _is_prepared boolean with _finish_task: Task | None that tracks the actual in-flight cleanup.
  • New is_ready property combines "no upcoming path" and "no cleanup in flight"; start() early-returns with a user-visible warning if called while a previous run is still cleaning up.
  • In the finally of start(), schedule finish() via rosys.background_tasks.create(...) instead of awaiting it — this sidesteps the GeneratorExit constraint while keeping cleanup tied to the automation's lifecycle.
  • finish() no longer guards on _is_prepared; it clears _finish_task at the end and notifies the user that the navigation was cleaned up.
  • Bump the pinned rosys revision to include rosys#403.

Risks / Notes

  • finish() now runs detached from start(), so wheels stop and implement deactivation complete shortly after the automator reports done. Subscribers to AUTOMATION_STOPPED / AUTOMATION_FAILED that assumed cleanup had finished must be reviewed.
  • If finish() itself raises, _finish_task is never cleared and the navigation stays in a non-ready state until the process restarts.

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • I chose meaningful labels (if GitHub allows me to so).
  • I documented breaking changes and set the 'breaking change' label if needed
  • The implementation is complete.
  • Tests with a real hardware have been successful (or are not necessary).
  • Pytests have been added (or are not necessary).
  • Documentation has been added (or is not necessary).

@pascalzauberzeug pascalzauberzeug added this to the 0.2.0 milestone May 5, 2026
@pascalzauberzeug pascalzauberzeug added the bug Something isn't working label May 5, 2026
@pascalzauberzeug pascalzauberzeug changed the title Fix automator stop Fix navigation cleanup under all exit paths May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant