From e1e302f93d7294261950fd26dee534749aff7f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 13 Feb 2019 12:06:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Allow=20slicing=20while=20printing?= =?UTF-8?q?=20on=20multi=20core=20systems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we don't know the number of cores or the number is less than two we the old behaviour still applies. Implements #1938 --- src/octoprint/plugin/types.py | 5 +++-- src/octoprint/server/api/files.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index 7ce4b2eb9..c82a64795 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -1853,8 +1853,9 @@ class SlicerPlugin(OctoPrintPlugin): The human readable name of the slicer. This will be displayed to the user during slicer selection. same_device True if the slicer runs on the same device as OctoPrint, False otherwise. Slicers running on the same - device will not be allowed to slice while a print is running due to performance reasons. Slice requests - against slicers running on the same device will result in an error. + device will not be allowed to slice on systems with less than two CPU cores (or an unknown number) while a + print is running due to performance reasons. Slice requests against slicers running on the same device and + less than two cores will result in an error. progress_report ``True`` if the slicer can report back slicing progress to OctoPrint ``False`` otherwise. source_file_types diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index e7916f1ed..077f8329b 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -544,9 +544,10 @@ def gcodeFileCommand(filename, target): if not any([octoprint.filemanager.valid_file_type(filename, type=source_file_type) for source_file_type in slicer_instance.get_slicer_properties().get("source_file_types", ["model"])]): return make_response("Cannot slice {filename}, not a model file".format(**locals()), 415) - if slicer_instance.get_slicer_properties().get("same_device", True) and (printer.is_printing() or printer.is_paused()): + cores = psutil.cpu_count() + if slicer_instance.get_slicer_properties().get("same_device", True) and (printer.is_printing() or printer.is_paused()) and (cores is None or cores < 2): # slicer runs on same device as OctoPrint, slicing while printing is hence disabled - return make_response("Cannot slice on {slicer} while printing due to performance reasons".format(**locals()), 409) + return make_response("Cannot slice on {slicer} while printing on single core systems or systems of unknown core count due to performance reasons".format(**locals()), 409) if "destination" in data and data["destination"]: destination = data["destination"]