Package Ganga :: Package Core :: Package GangaThread :: Module GangaThread'
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Core.GangaThread.GangaThread'

 1  from threading import Thread 
 2  from GangaThreadPool import GangaThreadPool 
 3  from Ganga.Utility.logging import getLogger 
 4   
 5  logger = getLogger('GangaThread') 
 6   
7 -class GangaThread(Thread):
8
9 - def __init__(self, name, auto_register=True, critical=True, **kwds):
10 11 name = 'GANGA_Update_Thread_%s' % name 12 13 Thread.__init__(self, name=name, **kwds) 14 self.setDaemon(True) 15 self.__should_stop_flag = False 16 self.__critical = critical 17 18 if auto_register: 19 tpool = GangaThreadPool.getInstance() 20 tpool.addServiceThread(self)
21
22 - def isCritical(self):
23 """Return critical flag. 24 25 @return: Boolean critical flag. 26 """ 27 return self.__critical
28
29 - def setCritical(self, critical):
30 """Set critical flag, which can be used for example in shutdown 31 algorithms. See Ganga/Core/__init__.py for example. 32 33 @param critical: Boolean critical flag. 34 """ 35 self.__critical = critical
36
37 - def should_stop(self):
38 return self.__should_stop_flag
39
40 - def stop(self):
41 if not self.__should_stop_flag: 42 logger.debug("Stopping: %s",self.getName()) 43 self.__should_stop_flag = True
44
45 - def unregister(self):
47