upxo.meshing.gbconformant.pipeline.background module
Run one stage in a separate process, watch its progress, cancel it at any moment.
The stage runs in a fresh Python process that restores the saved results of the stages
before it, runs the stage (which saves its own results), and reports through a file. The
caller’s PipelineState is changed only when the stage finishes, by reading the
saved results of that stage; a cancelled or failed stage leaves it as it was.
Usage:
job = StageProcess(state, "tet_mesh") # NotReady if the earlier results are not on disk
job.start()
while not job.done:
for event in job.poll(): ... # progress messages
time.sleep(0.1)
if job.outcome == "finished":
job.apply()
- exception upxo.meshing.gbconformant.pipeline.background.NotReady(reasons)[source]
Bases:
ExceptionThe stage cannot be run in a separate process;
reasonssay why.
- exception upxo.meshing.gbconformant.pipeline.background.IncompleteTransfer[source]
Bases:
ExceptionThe stage ran but some of its results could not be saved, so the caller cannot take them over.
- class upxo.meshing.gbconformant.pipeline.background.StageProcess(state: PipelineState, stage_id: str, *, python: str | None = None)[source]
Bases:
objectOne stage running in its own process.
- poll() list[dict][source]
New events since the last call (progress, then the final one); sets
donewhen the process is over.
- cancel() None[source]
Stop the stage now (the process and anything it started). The caller’s state stays as it was.
- upxo.meshing.gbconformant.pipeline.background.run_stage_separately(state: PipelineState, stage_id: str, on_event: Callable[[dict], None] | None = None, should_cancel: Callable[[], bool] | None = None, interval: float = 0.1) StageProcess[source]
Run
stage_idin a separate process and wait; the results are instatewhen the outcome isfinished.