mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Use buffered writing for writing gcode to removable drives
GCode files are still written line by line, but python is instructed to use buffering. This greatly decreases the total time required to write large(ish) files to USB drives, while having minimal impact on memory use. CURA-2544
This commit is contained in:
parent
0af42587b0
commit
d04e6a6644
1 changed files with 7 additions and 2 deletions
|
@ -23,6 +23,7 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
self.setPriority(1)
|
||||
|
||||
self._writing = False
|
||||
self._stream = None
|
||||
|
||||
def requestWrite(self, node, file_name = None, filter_by_machine = False):
|
||||
filter_by_machine = True # This plugin is indended to be used by machine (regardless of what it was told to do)
|
||||
|
@ -65,8 +66,8 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
|
||||
try:
|
||||
Logger.log("d", "Writing to %s", file_name)
|
||||
stream = open(file_name, "wt")
|
||||
job = WriteMeshJob(writer, stream, node, MeshWriter.OutputMode.TextMode)
|
||||
self._stream = open(file_name, "wt", buffering = 1)
|
||||
job = WriteMeshJob(writer, self._stream, node, MeshWriter.OutputMode.TextMode)
|
||||
job.setFileName(file_name)
|
||||
job.progress.connect(self._onProgress)
|
||||
job.finished.connect(self._onFinished)
|
||||
|
@ -92,6 +93,10 @@ class RemovableDriveOutputDevice(OutputDevice):
|
|||
self.writeProgress.emit(self, progress)
|
||||
|
||||
def _onFinished(self, job):
|
||||
if self._stream:
|
||||
self._stream.close()
|
||||
self._stream = None
|
||||
|
||||
if hasattr(job, "_message"):
|
||||
job._message.hide()
|
||||
job._message = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue