Definition at line 155 of file COOLRates.py.
◆ __init__()
def COOLRates.COOLQueryHandler.__init__ |
( |
|
self, |
|
|
|
mySignal, |
|
|
|
numProc = None , |
|
|
|
timeConverter = {} , |
|
|
|
verbose = False |
|
) |
| |
Definition at line 156 of file COOLRates.py.
156 def __init__(self,mySignal,numProc=None,timeConverter={},verbose=False):
157 self.troughQueue = Queue()
158 self.resultQueue = Queue()
159 self.QueryProcesses = []
162 self.verbose = verbose
163 self.timeConverter = timeConverter
164 self.mySignal = mySignal
165 if numProc
is None: numProc = cpu_count()
166 self.numProc = numProc
◆ addQueryBundle()
def COOLRates.COOLQueryHandler.addQueryBundle |
( |
|
self, |
|
|
|
queryBundle |
|
) |
| |
Definition at line 174 of file COOLRates.py.
174 def addQueryBundle(self,queryBundle):
176 self.troughQueue.put(queryBundle)
◆ beginQuery()
def COOLRates.COOLQueryHandler.beginQuery |
( |
|
self | ) |
|
Definition at line 178 of file COOLRates.py.
178 def beginQuery(self):
179 self.createProcesses()
180 for i
in range(self.numProc):
181 self.troughQueue.put(
True)
182 logger.info(
'{0} queries distributed over {1} workers'.
format(self.counter,len(self.QueryProcesses)))
183 for process
in self.QueryProcesses: process.start()
185 self.collectResults()
186 except KeyboardInterrupt:
187 logger.critical(
'Caught signal, terminating processes')
188 self.terminateProcesses()
190 for process
in self.QueryProcesses: process.join()
◆ collectResults()
def COOLRates.COOLQueryHandler.collectResults |
( |
|
self | ) |
|
Definition at line 211 of file COOLRates.py.
211 def collectResults(self):
213 startingQueries = self.counter
216 if not self.mySignal.is_alive():
217 raise KeyboardInterrupt
220 try: resultBundle = self.resultQueue.
get(
False,0.001)
224 if resultBundle
is True:
226 if finished == self.numProc:
break
229 percentComplete =
min(100,
int(
round(
float(startingQueries-self.counter)/startingQueries*100+.5)))
230 if percentComplete>=target:
232 logger.info(
'{0}% complete'.
format(percentComplete))
233 self.processResults(resultBundle)
◆ createProcesses()
def COOLRates.COOLQueryHandler.createProcesses |
( |
|
self | ) |
|
Reimplemented in COOLRates.RateQueryHandler.
Definition at line 168 of file COOLRates.py.
168 def createProcesses(self):
169 self.QueryProcesses = []
170 for i
in range(self.numProc):
171 process = Process(target = COOLQueryWorker(timeConverter=self.timeConverter), args = (self.troughQueue,self.resultQueue,))
172 self.QueryProcesses.
append(process)
◆ processResults()
def COOLRates.COOLQueryHandler.processResults |
( |
|
self, |
|
|
|
resultBundle |
|
) |
| |
Definition at line 193 of file COOLRates.py.
193 def processResults(self,resultBundle):
194 for resultAlias
in resultBundle:
195 if resultAlias
not in self.result: self.result[resultAlias]={}
196 self.result[resultAlias].
update(resultBundle[resultAlias])
◆ terminateProcesses()
def COOLRates.COOLQueryHandler.terminateProcesses |
( |
|
self | ) |
|
Definition at line 198 of file COOLRates.py.
198 def terminateProcesses(self):
200 try:self.troughQueue.
get(
False)
202 logger.critical(
'Queue is empty')
203 for i
in range(self.numProc): self.troughQueue.put(
True)
205 for process
in self.QueryProcesses:
208 logger.critical(
'Processes are joined')
209 raise KeyboardInterrupt
◆ counter
COOLRates.COOLQueryHandler.counter |
◆ mySignal
COOLRates.COOLQueryHandler.mySignal |
◆ numProc
COOLRates.COOLQueryHandler.numProc |
◆ QueryProcesses
COOLRates.COOLQueryHandler.QueryProcesses |
◆ result
COOLRates.COOLQueryHandler.result |
◆ resultQueue
COOLRates.COOLQueryHandler.resultQueue |
◆ timeConverter
COOLRates.COOLQueryHandler.timeConverter |
◆ troughQueue
COOLRates.COOLQueryHandler.troughQueue |
◆ verbose
COOLRates.COOLQueryHandler.verbose |
The documentation for this class was generated from the following file: