✨ Allow slicing while printing on multi core systems

If we don't know the number of cores or the number is less than two we
the old behaviour still applies.

Implements #1938
This commit is contained in:
Gina Häußge committed 2019-02-13 12:06:32 +01:00
1 parent 1cea388481
commit e1e302f93d
2 files changed
+6 -4

No files matched your search

+3 -2
View File
@@ -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
+3 -2
View File
@@ -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"]