Changes in / [4b001f3:38a1e63] in sasview


Ignore:
File:
1 edited

Legend:

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

    r33dc18f r33dc18f  
    1515import traceback 
    1616 
     17from Queue import Queue 
     18from threading import Thread 
    1719from collections import defaultdict 
    1820from wx.lib.scrolledpanel import ScrolledPanel 
     
    241243        self.set_layout() 
    242244 
     245        # Setting up a thread for the fitting 
     246        self.threaded_draw_queue = Queue() 
     247 
     248        self.draw_worker_thread = Thread(target = self._threaded_draw_worker, 
     249                                         args = (self.threaded_draw_queue,)) 
     250        self.draw_worker_thread.setDaemon(True) 
     251        self.draw_worker_thread.start() 
     252 
     253        # And a home for the thread submission times 
     254        self.last_time_fit_submitted = 0.00 
     255 
    243256    def set_index_model(self, index): 
    244257        """ 
     
    16931706        :param chisqr: update chisqr value [bool] 
    16941707        """ 
    1695         wx.CallAfter(self._draw_model_after, update_chisqr, source) 
     1708        self.threaded_draw_queue.put([copy.copy(update_chisqr), copy.copy(source)]) 
     1709 
     1710    def _threaded_draw_worker(self, threaded_draw_queue): 
     1711        while True: 
     1712            # sit and wait for the next task 
     1713            next_task = threaded_draw_queue.get() 
     1714 
     1715            # sleep for 1/10th second in case some other tasks accumulate 
     1716            time.sleep(0.1) 
     1717 
     1718            # skip all intermediate tasks 
     1719            while self.threaded_draw_queue.qsize() > 0: 
     1720                self.threaded_draw_queue.task_done() 
     1721                next_task = self.threaded_draw_queue.get() 
     1722 
     1723            # and finally, do the task 
     1724            self._draw_model_after(*next_task) 
     1725            threaded_draw_queue.task_done() 
    16961726 
    16971727    def _draw_model_after(self, update_chisqr=True, source='model'): 
     
    17161746            toggle_mode_on = self.model_view.IsEnabled() 
    17171747            is_2d = self._is_2D() 
     1748 
    17181749            self._manager.draw_model(self.model, 
    17191750                                     data=self.data, 
Note: See TracChangeset for help on using the changeset viewer.