Changeset 7adc2a8 in sasview


Ignore:
Timestamp:
Aug 1, 2017 3:12:36 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
985ad94
Parents:
0d13814
Message:

Allow old style threads for fitting

Location:
src/sas/qtgui/Perspectives/Fitting
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FitThread.py

    rdc5ef15 r7adc2a8  
    7474                         list_reset_flag) 
    7575            result = map(map_apply, inputs) 
    76  
    77             self.complete(result=result, 
    78                           batch_inputs=self.batch_inputs, 
    79                           batch_outputs=self.batch_outputs, 
    80                           page_id=self.page_id, 
    81                           pars=self.pars, 
    82                           elapsed=time.time() - self.starttime) 
    83  
    84             return result[0], time.time()-self.starttime 
     76            results = (result[0], time.time()-self.starttime) 
     77            if self.handler: 
     78                self.completefn(results) 
     79            else: 
     80                return (results) 
    8581 
    8682        except KeyboardInterrupt, msg: 
     
    9692                self.handler.stop(msg=msg) 
    9793        except Exception as ex: 
     94            # print "ERROR IN FIT THREAD: ", traceback.format_exc() 
    9895            if self.handler is not None: 
    9996                self.handler.error(msg=traceback.format_exc()) 
  • src/sas/qtgui/Perspectives/Fitting/FittingWidget.py

    r0d13814 r7adc2a8  
    2727from sas.qtgui.Perspectives.Fitting.UI.FittingWidgetUI import Ui_FittingWidgetUI 
    2828from sas.qtgui.Perspectives.Fitting.FitThread import FitThread 
     29from sas.qtgui.Perspectives.Fitting.ConsoleUpdate import ConsoleUpdate 
     30 
    2931from sas.qtgui.Perspectives.Fitting.ModelThread import Calc1D 
    3032from sas.qtgui.Perspectives.Fitting.ModelThread import Calc2D 
     
    4547 
    4648DEFAULT_POLYDISP_FUNCTION = 'gaussian' 
     49 
     50USING_TWISTED = True 
    4751 
    4852class FittingWidget(QtGui.QWidget, Ui_FittingWidgetUI): 
     
    636640        list_page_id = [page_id] 
    637641        #--------------------------------- 
     642        if USING_TWISTED: 
     643            handler = None 
     644            updater = None 
     645        else: 
     646            handler = ConsoleUpdate(parent=self.parent, 
     647                                    manager=self, 
     648                                    improvement_delta=0.1) 
     649            updater = handler.update_fit 
    638650 
    639651        # Parameterize the fitter 
     
    653665                             batch_outputs=batch_outputs, 
    654666                             page_id=list_page_id, 
    655                              updatefn=self.updateFit, 
    656                              completefn=None) 
    657  
    658         # start the trhrhread 
    659         calc_thread = threads.deferToThread(calc_fit.compute) 
    660         calc_thread.addCallback(self.fitComplete) 
    661         calc_thread.addErrback(self.fitFailed) 
     667                             updatefn=updater, 
     668                             completefn=self.fitComplete) 
     669 
     670        if USING_TWISTED: 
     671            # start the trhrhread with twisted 
     672            calc_thread = threads.deferToThread(calc_fit.compute) 
     673            calc_thread.addCallback(self.fitComplete) 
     674            calc_thread.addErrback(self.fitFailed) 
     675        else: 
     676            # Use the old python threads + Queue 
     677            calc_fit.queue() 
     678            calc_fit.ready(2.5) 
     679 
    662680 
    663681        #disable the Fit button 
    664         self.cmdFit.setText('Calculating...') 
     682        self.cmdFit.setText('Running...') 
    665683        self.communicate.statusBarUpdateSignal.emit('Fitting started...') 
    666684        self.cmdFit.setEnabled(False) 
Note: See TracChangeset for help on using the changeset viewer.