Changeset 131791e in sasview for src/sas/sasgui/perspectives/fitting/basepage.py
- Timestamp:
- Apr 7, 2017 9:47:34 AM (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
r9c0f3c17 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.