VultureChecker/VultureCheckerService.py

changeset 47
4e19b213fc3f
parent 45
232ed15782bb
child 49
7b55dc5d09d2
equal deleted inserted replaced
46:9f7a962f3655 47:4e19b213fc3f
12 try: 12 try:
13 str = unicode # __IGNORE_EXCEPTION__ __IGNORE_WARNING__ 13 str = unicode # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
14 except NameError: 14 except NameError:
15 pass 15 pass
16 16
17 import sys
17 import multiprocessing 18 import multiprocessing
18 import sys 19 import queue
19 20
20 from vulture import Vulture 21 from vulture import Vulture
21 22
22 23
23 def initService(): 24 def initService():
87 .start() 88 .start()
88 89
89 # Get and send results 90 # Get and send results
90 endIndex = len(argumentsList) - initialTasks 91 endIndex = len(argumentsList) - initialTasks
91 for i in range(len(argumentsList)): 92 for i in range(len(argumentsList)):
92 filename, result = doneQueue.get() 93 resultSent = False
93 send(fx, filename, result) 94 wasCancelled = False
94 if cancelled(): 95
96 while not resultSent:
97 try:
98 # get result (waiting max. 3 seconds and send it to frontend
99 filename, result = doneQueue.get()
100 send(fx, filename, result)
101 resultSent = True
102 except queue.Empty:
103 # ignore empty queue, just carry on
104 if cancelled():
105 wasCancelled = True
106 break
107
108 if wasCancelled or cancelled():
95 # just exit the loop ignoring the results of queued tasks 109 # just exit the loop ignoring the results of queued tasks
96 break 110 break
111
97 if i < endIndex: 112 if i < endIndex:
98 taskQueue.put(argumentsList[i + initialTasks]) 113 taskQueue.put(argumentsList[i + initialTasks])
99 114
100 # Tell child processes to stop 115 # Tell child processes to stop
101 for i in range(NumberOfProcesses): 116 for i in range(NumberOfProcesses):

eric ide

mercurial