source: sasview/calculatorview/src/sans/perspectives/calculator/load_thread.py @ 72538fc

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 72538fc was 7343319, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Fixing code style problems

  • Property mode set to 100644
File size: 1.3 KB
Line 
1"""
2    Thread handler used to load data
3"""
4import time
5from data_util.calcthread import CalcThread
6from sans.dataloader.loader import Loader
7       
8class DataReader(CalcThread):
9    """
10        Load a data given a filename
11    """
12    def __init__(self, path, completefn=None,
13                 updatefn   = None,
14                 yieldtime  = 0.01,
15                 worktime   = 0.01
16                 ):
17        CalcThread.__init__(self, completefn,
18                 updatefn,
19                 yieldtime,
20                 worktime)
21        self.path = path
22        #Instantiate a loader
23        self.loader = Loader()
24        self.starttime = 0 
25       
26    def isquit(self):
27        """
28             @raise KeyboardInterrupt: when the thread is interrupted
29        """
30        try:
31            CalcThread.isquit(self)
32        except KeyboardInterrupt:
33            raise KeyboardInterrupt   
34       
35       
36    def compute(self):
37        """
38            read some data
39        """
40        self.starttime = time.time()
41        try:
42            data =  self.loader.load(self.path)
43            self.complete(data=data)
44        except KeyboardInterrupt:
45            # Thread was interrupted, just proceed and re-raise.
46            # Real code should not print, but this is an example...
47            raise
48     
Note: See TracBrowser for help on using the repository browser.