From ec29a1999f39fc6091b3a5043ac45e4dcd86b4b8 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 24 Dec 2025 17:05:10 +0000 Subject: [PATCH] Update how stitching is called in Windows --- src/openflexure_microscope_server/stitching.py | 11 +++++++++-- tests/unit_tests/test_stitching.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/stitching.py b/src/openflexure_microscope_server/stitching.py index 8eb7be1e..e505971f 100644 --- a/src/openflexure_microscope_server/stitching.py +++ b/src/openflexure_microscope_server/stitching.py @@ -18,6 +18,8 @@ import labthings_fastapi as lt from openflexure_microscope_server.utilities import make_path_safe +IS_WINDOWS = os.name == "nt" + STITCHING_CMD = "openflexure-stitch" STITCHING_RESOLUTION = (820, 616) STITCH_TILE_SIZE = 8192 @@ -95,7 +97,8 @@ class BaseStitcher: self.validate_path() # The command, and the mode - initial_args = shlex.split(STITCHING_CMD) + ["--stitching_mode", self._mode] + base_args = shlex.split(STITCHING_CMD, posix=not IS_WINDOWS) + initial_args = base_args + ["--stitching_mode", self._mode] # Use float() just to really ensure that anything input is a float setting_args = [ "--minimum_overlap", @@ -181,7 +184,11 @@ class PreviewStitcher(BaseStitcher): except lt.exceptions.InvocationCancelledError as e: with self._popen_lock: if self._popen_obj is not None: - self._popen_obj.send_signal(signal.SIGKILL) + if IS_WINDOWS: + # Windows has no SIGKILL + self._popen_obj.kill() + else: + self._popen_obj.send_signal(signal.SIGKILL) raise (e) diff --git a/tests/unit_tests/test_stitching.py b/tests/unit_tests/test_stitching.py index 31918f41..12bcfbfb 100644 --- a/tests/unit_tests/test_stitching.py +++ b/tests/unit_tests/test_stitching.py @@ -235,6 +235,7 @@ class StitchingTestThing(lt.Thing): """Run the final stitcher.""" stitcher = FinalStitcher(FAKE_DIR, logger=self.logger) # Send in the argument HANG to mock-stitch and it just hang for 10s + stitcher._extra_args = ["HANG"] stitcher.run()