Changes in / [861f1880:131791e] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r463e7ffc r4b402a1 13 13 import traceback 14 14 15 from time import time 16 from Queue import Queue 17 from threading import Thread 15 18 from collections import defaultdict 16 19 from wx.lib.scrolledpanel import ScrolledPanel … … 239 242 self.set_layout() 240 243 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 241 255 def set_index_model(self, index): 242 256 """ … … 1691 1705 :param chisqr: update chisqr value [bool] 1692 1706 """ 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' 1694 1744 1695 1745 def _draw_model_after(self, update_chisqr=True, source='model'): … … 1714 1764 toggle_mode_on = self.model_view.IsEnabled() 1715 1765 is_2d = self._is_2D() 1766 1716 1767 self._manager.draw_model(self.model, 1717 1768 data=self.data,
Note: See TracChangeset
for help on using the changeset viewer.