Update stiching to differentiate bwtween stitchers that use a thread and those that block

This commit is contained in:
Julian Stirling 2025-08-06 17:47:33 +01:00
parent 5f092835ac
commit cd311f08bf
3 changed files with 11 additions and 18 deletions

View file

@ -44,7 +44,12 @@ def validate_command(cmd: list[str]):
class BaseStitcher:
"""A base stitching class for all stitchers. Don't initialise this directly."""
"""A base stitching class for all stitchers. Don't initialise this directly.
The base class has no way to run the command. Child classes should either implement
a ``start``, ``running``, and ``wait`` methods if they stitch in a thread, or ``run``
if they stitch in this thread and return once complete.
"""
def __init__(self, images_dir: str, *, overlap: float, correlation_resize: float):
"""Initialise a stitcher.
@ -104,15 +109,6 @@ class BaseStitcher:
"Invalid directory path: Contains unsafe characters."
)
def start(self) -> None:
"""Start stitching a stitching process.
This should be overridden by any child class.
"""
raise NotImplementedError(
"Child stitchers should implement their own ``start`` method."
)
class PreviewStitcher(BaseStitcher):
"""A stitcher for stitching an ongoing scan in preview mode.
@ -262,7 +258,7 @@ class FinalStitcher(BaseStitcher):
)
return overlap, correlation_resize
def start(
def run(
self,
cancel: lt.deps.CancelHook,
) -> None:

View file

@ -715,7 +715,7 @@ class SmartScanThing(lt.Thing):
)
try:
# start the final stitch, providing the cancel hook to allow aborting
final_stitcher.start(cancel)
final_stitcher.run(cancel)
except lt.exceptions.InvocationCancelledError:
# Sleep for 1 second just to allow invocation logs to pass to user.
time.sleep(1)