Skip to content

feat: Blueapi plan pause#1589

Draft
Alexj9837 wants to merge 2 commits into
mainfrom
plan-pause
Draft

feat: Blueapi plan pause#1589
Alexj9837 wants to merge 2 commits into
mainfrom
plan-pause

Conversation

@Alexj9837

Copy link
Copy Markdown
Contributor

Bluesky's RunEngine pauses via a RunEngineInterrupted, but blueapi was treating that exception like any other plan failure , pausing a task marked it as failed instead of leaving it resumable. On top of that, resume() and cancel_active_task() mutated RunEngine state directly from the calling thread, racing with the worker thread that owns it, which could leave a paused RunEngine stuck forever, apply a stale cancel, or double-set a task's outcome.

Alexj9837 added 2 commits July 8, 2026 12:19
…ead signals

Route resume() and cancel_active_task() through the worker thread's
signal queue instead of mutating state directly from the caller, so
state stays consistent across pause/resume/cancel transitions. Includes
tests and a fix for cancel_active_task() when the RunEngine is already
in a paused state.
- Resolve a paused task before stopping the worker, instead of leaving
  the RunEngine paused and the task incomplete forever with no thread
  left to resolve it.
- Apply the latest cancel_active_task() request while paused instead of
  a stale queued one.
- Prevent a race between the caller thread and worker thread when
  recording a cancelled task's outcome.
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.86047% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.11%. Comparing base (32c57b9) to head (1d3afe7).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/blueapi/worker/task_worker.py 91.86% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1589      +/-   ##
==========================================
+ Coverage   95.93%   96.11%   +0.18%     
==========================================
  Files          44       44              
  Lines        3270     3322      +52     
==========================================
+ Hits         3137     3193      +56     
+ Misses        133      129       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

try:
result = self._ctx.run_engine.resume()
self._current.set_result(result)
except RunEngineInterrupted:
Object put in the worker's task queue to tell it to resume if paused.
"""

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant