mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
CURA-1923: Slicinfo: Using UM.Job instead
As suggested by @awhiemstra handling our "thread" here should be done with UM.Job.
This commit is contained in:
parent
7ab0332a6d
commit
260b682864
1 changed files with 14 additions and 13 deletions
|
@ -11,8 +11,9 @@ from UM.i18n import i18nCatalog
|
|||
from UM.Logger import Logger
|
||||
from UM.Platform import Platform
|
||||
from UM.Qt.Duration import DurationFormat
|
||||
from UM.Job import Job
|
||||
|
||||
from threading import Thread
|
||||
import time
|
||||
import platform
|
||||
import math
|
||||
import urllib.request
|
||||
|
@ -21,12 +22,12 @@ import ssl
|
|||
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
class SliceInfoThread(Thread):
|
||||
class SliceInfoThread(Job):
|
||||
data = None
|
||||
url = None
|
||||
|
||||
def __init__(self, url, data):
|
||||
Thread.__init__(self)
|
||||
Job.__init__(self)
|
||||
self.url = url
|
||||
self.data = data
|
||||
|
||||
|
@ -68,17 +69,17 @@ class SliceInfo(Extension):
|
|||
self.send_slice_info_message.actionTriggered.connect(self.messageActionTriggered)
|
||||
self.send_slice_info_message.show()
|
||||
|
||||
self.runningThreads = []
|
||||
self.runningJobs = []
|
||||
|
||||
def __del__(self):
|
||||
for thread in self.threadedReports:
|
||||
if thread.is_alive():
|
||||
thread.join() # Wait for threads - shouldn't take much more time than the timeout. See above..
|
||||
for job in self.runningJobs:
|
||||
while not job.isFinished():
|
||||
time.sleep(1) # Wait for threads - shouldn't take much more time than the timeout. See above..
|
||||
|
||||
def _removeFinishedThreads(self):
|
||||
for process in self.runningThreads:
|
||||
if not process.is_alive():
|
||||
self.runningThreads.remove(process) # Remove finished threads
|
||||
for job in self.runningJobs:
|
||||
if job.isFinished():
|
||||
self.runningJobs.remove(job) # Remove finished threads
|
||||
|
||||
def messageActionTriggered(self, message_id, action_id):
|
||||
self.send_slice_info_message.hide()
|
||||
|
@ -152,9 +153,9 @@ class SliceInfo(Extension):
|
|||
binary_data = submitted_data.encode("utf-8")
|
||||
|
||||
# Sending slice info non-blocking
|
||||
reportThread = SliceInfoThread(self.info_url, binary_data)
|
||||
self.runningThreads.append(reportThread)
|
||||
reportThread.start()
|
||||
reportJob = SliceInfoThread(self.info_url, binary_data)
|
||||
self.runningJobs.append(reportJob)
|
||||
reportJob.start()
|
||||
except:
|
||||
# We really can't afford to have a mistake here, as this would break the sending of g-code to a device
|
||||
# (Either saving or directly to a printer). The functionality of the slice data is not *that* important.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue