106 .start() |
107 .start() |
107 |
108 |
108 # Get and send results |
109 # Get and send results |
109 endIndex = len(argumentsList) - initialTasks |
110 endIndex = len(argumentsList) - initialTasks |
110 for i in range(len(argumentsList)): |
111 for i in range(len(argumentsList)): |
111 filename, result = doneQueue.get() |
112 resultSent = False |
112 send(fx, filename, result) |
113 wasCancelled = False |
113 if cancelled(): |
114 |
|
115 while not resultSent: |
|
116 try: |
|
117 # get result (waiting max. 3 seconds and send it to frontend |
|
118 filename, result = doneQueue.get() |
|
119 send(fx, filename, result) |
|
120 resultSent = True |
|
121 except queue.Empty: |
|
122 # ignore empty queue, just carry on |
|
123 if cancelled(): |
|
124 wasCancelled = True |
|
125 break |
|
126 |
|
127 if wasCancelled or cancelled(): |
114 # just exit the loop ignoring the results of queued tasks |
128 # just exit the loop ignoring the results of queued tasks |
115 break |
129 break |
|
130 |
116 if i < endIndex: |
131 if i < endIndex: |
117 taskQueue.put(argumentsList[i + initialTasks]) |
132 taskQueue.put(argumentsList[i + initialTasks]) |
118 |
133 |
119 # Tell child processes to stop |
134 # Tell child processes to stop |
120 for i in range(NumberOfProcesses): |
135 for i in range(NumberOfProcesses): |