Changeset 934ce649 in sasview for src/sas/sascalc/data_util
- Timestamp:
- May 23, 2016 4:48:46 PM (9 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b6f563b4
- Parents:
- 52b7fd9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/calcthread.py
rb699768 r934ce649 119 119 120 120 def __init__(self, completefn=None, updatefn=None, 121 yieldtime=0.01, worktime=0.01): 121 yieldtime=0.01, worktime=0.01, 122 exception_handler=None): 122 123 """Prepare the calculator""" 123 124 self.yieldtime = yieldtime … … 125 126 self.completefn = completefn 126 127 self.updatefn = updatefn 128 self.exception_handler = exception_handler 127 129 self._interrupting = False 128 130 self._running = False … … 199 201 200 202 def update(self, **kwargs): 201 202 203 """Update GUI with the lastest results from the current work unit.""" 203 204 if self.updatefn != None and clock() > self._time_for_update: … … 225 226 """Perform a work unit. The subclass will provide details of 226 227 the arguments.""" 227 raise NotImplemented, "Calculation thread needs compute method" 228 raise NotImplemented("Calculation thread needs compute method") 229 230 def exception(self): 231 """ 232 An exception occurred during computation, so call the exception handler 233 if there is one. If not, then log the exception and continue. 234 """ 235 # If we have an exception handler, let it try to handle the exception. 236 # If it fails fall through to log the failure to handle the exception 237 # (the original exception will be lost). If there is no exception 238 # handler, just log the exception in compute that we are responding to. 239 if self.exception_handler: 240 try: 241 self.exception_handler(*sys.exc_info()) 242 return 243 except Exception: 244 pass 245 import logging 246 logging.error(traceback.format_exc()) 247 #print 'CalcThread exception', 228 248 229 249 def _run(self): … … 250 270 pass 251 271 except: 252 traceback.print_exc() 253 #print 'CalcThread exception', 272 self.exception() 254 273 self._running = False 255 274
Note: See TracChangeset
for help on using the changeset viewer.