Commit 1419b97c authored by payno's avatar payno

[orangecontrib] change behavior processing thread

Now if a new request is required for processing and the processing thread is running, skip the request. Simplify thing.
parent d0fb21f4
Pipeline #12441 failed with stage
in 60 minutes
......@@ -48,7 +48,11 @@ class _PyMcaProcessForOrangeMixIn(object):
# progress
self._progress = gui.ProgressBar(self, 100)
def _startProcess(self):
self._window.setEnabled(False)
def _endProcess(self, xas_obj):
self._window.setEnabled(True)
if self._callback_finish:
try:
self.getProcessingThread()._process_obj._advancement.sigProgress.disconnect(self._setProgressValue)
......@@ -64,12 +68,8 @@ class _PyMcaProcessForOrangeMixIn(object):
# emit signal for the plot
self.send("spectra", xas_obj)
def _stopProcessing(self):
if self.__processingThread is None:
return
else:
self.__processingThread.finished.disconnect(self._callback_finish)
self.__processingThread.quit()
def _canProcess(self):
return self.__processingThread is None or not self.__processingThread.isRunning()
def getProcessingThread(self):
if self.__processingThread is None:
......
......@@ -198,8 +198,12 @@ class ExafsOW(_PyMcaProcessForOrangeMixIn, OWWidget):
if xas_obj is None:
return
self._stopProcessing()
if not self._canProcess():
_logger.warning('There is some processing on going already, will'
'not process the new dataset')
self._latest_xas_obj = xas_obj.copy()
self._startProcess()
# setup the exafs process
process_obj = QPyMca_exafs()
......
......@@ -166,8 +166,12 @@ class FTOW(_PyMcaProcessForOrangeMixIn, OWWidget):
if xas_obj is None:
return
self._stopProcessing()
if not self._canProcess():
_logger.warning('There is some processing on going already, will'
'not process the new dataset')
self._latest_xas_obj = xas_obj.copy()
self._startProcess()
# setup the ft process
process_obj = QPyMca_ft()
......
......@@ -185,15 +185,18 @@ class KWeightOW(_PyMcaProcessForOrangeMixIn, OWWidget):
if xas_obj is None:
return
self._stopProcessing()
if not self._canProcess():
_logger.warning('There is some processing on going already, will'
'not process the new dataset')
self._latest_xas_obj = xas_obj.copy()
self._startProcess()
# setup the k weight process
process_obj = QPyMca_k_weight()
process_obj._advancement.sigProgress.connect(self._setProgressValue)
process_obj.setProperties({'_kWeightSetting': self._window._k_spin_box.value()})
# update the processing thread
# update the processing thread
thread = self.getProcessingThread()
thread.init(process_obj=process_obj, xas_obj=xas_obj)
......
......@@ -208,8 +208,12 @@ class NormalizationOW(_PyMcaProcessForOrangeMixIn, OWWidget):
if xas_obj is None:
return
self._stopProcessing()
if not self._canProcess():
_logger.warning('There is some processing on going already, will'
'not process the new dataset')
self._latest_xas_obj = xas_obj.copy()
self._startProcess()
# setup the normalization process
process_obj = QPyMca_normalization()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment