Skip to content

feat: Blueapi plan pause#1589

Open
Alexj9837 wants to merge 7 commits into
mainfrom
plan-pause
Open

feat: Blueapi plan pause#1589
Alexj9837 wants to merge 7 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.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72727% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.31%. Comparing base (f0c73cd) to head (f6f82cb).

Files with missing lines Patch % Lines
src/blueapi/worker/task_worker.py 97.72% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1589      +/-   ##
==========================================
+ Coverage   95.93%   96.31%   +0.37%     
==========================================
  Files          44       44              
  Lines        3300     3369      +69     
==========================================
+ Hits         3166     3245      +79     
+ Misses        134      124      -10     

☔ 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.

Comment thread src/blueapi/worker/task_worker.py Fixed
Comment thread src/blueapi/worker/task_worker.py Fixed
…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.
racing the worker thread's own finalization, which could report a
completed task with no result.
@Alexj9837
Alexj9837 marked this pull request as ready for review July 14, 2026 11:33
@Alexj9837
Alexj9837 requested a review from a team as a code owner July 14, 2026 11:33
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