Ignore:
Timestamp:
Apr 7, 2017 9:47:34 AM (7 years ago)
Author:
Tim Snow <tim.snow@…>
Branches:
master, 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
503eb52
Parents:
4b402a1 (diff), 861f1880 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ticket-869

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r9c0f3c17 r4b402a1  
    1313import traceback 
    1414 
     15from time import time 
     16from Queue import Queue 
     17from threading import Thread 
    1518from collections import defaultdict 
    1619from wx.lib.scrolledpanel import ScrolledPanel 
     
    239242        self.set_layout() 
    240243 
     244        # Setting up a thread for the fitting 
     245        self.threadedDrawQueue = Queue() 
     246 
     247        self.threadedDrawWorker = Thread(target = self._threaded_draw_worker, 
     248                                         args = (self.threadedDrawQueue,)) 
     249        self.threadedDrawWorker.setDaemon(True) 
     250        self.threadedDrawWorker.start() 
     251 
     252        # And a home for the thread submission times 
     253        self.lastTimeFitSubmitted = 0.00 
     254 
    241255    def set_index_model(self, index): 
    242256        """ 
     
    16911705        :param chisqr: update chisqr value [bool] 
    16921706        """ 
    1693         wx.CallAfter(self._draw_model_after, update_chisqr, source) 
     1707        # Get the time 
     1708        currentTime = time() 
     1709 
     1710        # When loading we slam a number of fits through here 
     1711        # let's filter these out to start with 
     1712        if currentTime > (self.lastTimeFitSubmitted + 0.1): 
     1713            # Submitting the rest 
     1714            self.threadedDrawQueue.put([update_chisqr, source]) 
     1715            print 'submitted!' 
     1716        else: 
     1717            pass 
     1718 
     1719        self.lastTimeFitSubmitted = currentTime 
     1720 
     1721    def _threaded_draw_worker(self, threadedDrawQueue): 
     1722        while True: 
     1723            # Check to see is a manager is running and a calc is running 
     1724            if ((self._manager.calc_1D is not None) and (self._manager.calc_1D.\ 
     1725                isrunning() == True)) or ((self._manager.calc_2D is not None)\ 
     1726                and (self._manager.calc_2D.isrunning() == True)): 
     1727                # If a manager is running a calculation  
     1728                # then trim the queue 
     1729                if self.threadedDrawQueue.qsize() > 1: 
     1730                    print '2' 
     1731                    for loopIter in range(threadedDrawQueue.qsize() - 1): 
     1732                        dump = self.threadedDrawQueue.get() 
     1733                        self.threadedDrawQueue.task_done() 
     1734                        print 'bounced' 
     1735                    print 'one element left' 
     1736            else: 
     1737                # Otherwise, just run 
     1738                inputVariables = threadedDrawQueue.get() 
     1739                self._draw_model_after(inputVariables[0], inputVariables[1]) 
     1740                wx.PostEvent(self._manager.parent, StatusEvent(status =  
     1741                            "Computation is in progress...", type = "progress")) 
     1742                threadedDrawQueue.task_done() 
     1743                print 'run'                 
    16941744 
    16951745    def _draw_model_after(self, update_chisqr=True, source='model'): 
     
    17141764            toggle_mode_on = self.model_view.IsEnabled() 
    17151765            is_2d = self._is_2D() 
     1766 
    17161767            self._manager.draw_model(self.model, 
    17171768                                     data=self.data, 
Note: See TracChangeset for help on using the changeset viewer.