From b4612539585c1e9f4e75e0ad084da81f0ad758d3 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 30 Jan 2023 23:55:18 -0500 Subject: make simulator threads pre-emptible --- lib/elements/fill_stitch.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/elements') diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index 7de293cb..eef8341c 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -22,6 +22,7 @@ from ..svg.tags import INKSCAPE_LABEL from ..utils import cache, version from .element import EmbroideryElement, param from .validation import ValidationError, ValidationWarning +from ..utils.threading import ExitThread class SmallShapeWarning(ValidationWarning): @@ -571,6 +572,8 @@ class FillStitch(EmbroideryElement): stitch_groups.extend(self.do_contour_fill(fill_shape, last_patch, start)) elif self.fill_method == 2: stitch_groups.extend(self.do_guided_fill(fill_shape, last_patch, start, end)) + except ExitThread: + raise except Exception: self.fatal_fill_error() last_patch = stitch_groups[-1] -- cgit v1.2.3 From f6c2aa89197c82cedfb31465fc4b2acffaeb8f25 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sun, 5 Feb 2023 22:33:38 -0500 Subject: add more check_stop_flag() calls --- lib/elements/satin_column.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/elements') diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index be614a04..4028ad27 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -21,6 +21,7 @@ from ..utils import Point, cache, cut, cut_multiple, prng from ..stitches import running_stitch from .element import EmbroideryElement, param, PIXELS_PER_MM from .validation import ValidationError, ValidationWarning +from ..utils.threading import check_stop_flag class TooFewPathsError(ValidationError): @@ -818,10 +819,12 @@ class SatinColumn(EmbroideryElement): index1 = 0 while index0 < last_index0 and index1 < last_index1: + check_stop_flag() + # Each iteration of this outer loop is one stitch. Keep going # until we fall off the end of the section. - old_center = shgeo.Point(x/2 for x in (pos0 + pos1)) + old_center = shgeo.Point(x / 2 for x in (pos0 + pos1)) while to_travel > 0 and index0 < last_index0 and index1 < last_index1: # In this loop, we inch along each rail a tiny bit per -- cgit v1.2.3