Dedup workers: one _PooledWorker base for the three pool fan-outs

DcPrecomputeWorker, Ch4MaskWorker and CrossCorrelateWorker shared the
same submit/as_completed/emit/shutdown skeleton; they are now
constructors plus _plan/_items/_one/_emit hooks. All three inherit the
cancellation-aware shutdown (wait=not stopped, cancel_futures) that
only DcPrecomputeWorker had before, and the per-run budget attributes
are initialised in __init__ instead of appearing mid-run.

Also removes the viewer's write-only _dc_precompute_worker plumbing
(job tracking already owns worker lifetime via _jobs).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Thomas Ales
2026-08-06 10:32:06 -05:00
parent 9a9a2557d6
commit e80717d5c5
2 changed files with 67 additions and 76 deletions
+1 -6
View File
@@ -1478,7 +1478,6 @@ class SrasViewerWindow(QMainWindow):
# same combination is free.
self._dc_cache: dict[tuple[int, int], np.ndarray] = {}
self._fft_cache: dict[tuple[int, bool, int | None, float], np.ndarray] = {}
self._dc_precompute_worker: DcPrecomputeWorker | None = None
self._dc_generation: int = 0
# Angle alignment ("Fusion" menu)
@@ -2463,8 +2462,7 @@ class SrasViewerWindow(QMainWindow):
n_angles = self._sras.n_angles
worker = DcPrecomputeWorker(self._sras)
self._dc_precompute_worker = worker
started = self._run_worker(
self._run_worker(
"dc_precompute", worker,
connect=(
("angle_done", lambda a, dc3, dc4, g=generation:
@@ -2473,10 +2471,7 @@ class SrasViewerWindow(QMainWindow):
f"DC precompute error: {msg}", 5000)),
),
quit_on=("finished", "error"),
on_done=lambda: setattr(self, "_dc_precompute_worker", None),
)
if not started:
self._dc_precompute_worker = None
def _on_dc_precompute_angle_done(self, generation: int, angle_idx: int,
dc3_mv: np.ndarray, dc4_mv: np.ndarray,