145 .start() |
146 .start() |
146 |
147 |
147 # Get and send results |
148 # Get and send results |
148 endIndex = len(argumentsList) - initialTasks |
149 endIndex = len(argumentsList) - initialTasks |
149 for i in range(len(argumentsList)): |
150 for i in range(len(argumentsList)): |
150 filename, result = doneQueue.get() |
151 resultSent = False |
151 send(fx, filename, result) |
152 wasCancelled = False |
152 if cancelled(): |
153 |
|
154 while not resultSent: |
|
155 try: |
|
156 # get result (waiting max. 3 seconds and send it to frontend |
|
157 filename, result = doneQueue.get() |
|
158 send(fx, filename, result) |
|
159 resultSent = True |
|
160 except queue.Empty: |
|
161 # ignore empty queue, just carry on |
|
162 if cancelled(): |
|
163 wasCancelled = True |
|
164 break |
|
165 |
|
166 if wasCancelled or cancelled(): |
153 # just exit the loop ignoring the results of queued tasks |
167 # just exit the loop ignoring the results of queued tasks |
154 break |
168 break |
|
169 |
155 if i < endIndex: |
170 if i < endIndex: |
156 taskQueue.put(argumentsList[i + initialTasks]) |
171 taskQueue.put(argumentsList[i + initialTasks]) |
157 |
172 |
158 # Tell child processes to stop |
173 # Tell child processes to stop |
159 for i in range(NumberOfProcesses): |
174 for i in range(NumberOfProcesses): |