84 .start() |
85 .start() |
85 |
86 |
86 # Get and send results |
87 # Get and send results |
87 endIndex = len(argumentsList) - initialTasks |
88 endIndex = len(argumentsList) - initialTasks |
88 for i in range(len(argumentsList)): |
89 for i in range(len(argumentsList)): |
89 filename, result = doneQueue.get() |
90 resultSent = False |
90 send(fx, filename, result) |
91 wasCancelled = False |
91 if cancelled(): |
92 |
|
93 while not resultSent: |
|
94 try: |
|
95 # get result (waiting max. 3 seconds and send it to frontend |
|
96 filename, result = doneQueue.get() |
|
97 send(fx, filename, result) |
|
98 resultSent = True |
|
99 except queue.Empty: |
|
100 # ignore empty queue, just carry on |
|
101 if cancelled(): |
|
102 wasCancelled = True |
|
103 break |
|
104 |
|
105 if wasCancelled or cancelled(): |
92 # just exit the loop ignoring the results of queued tasks |
106 # just exit the loop ignoring the results of queued tasks |
93 break |
107 break |
|
108 |
94 if i < endIndex: |
109 if i < endIndex: |
95 taskQueue.put(argumentsList[i + initialTasks]) |
110 taskQueue.put(argumentsList[i + initialTasks]) |
96 |
111 |
97 # Tell child processes to stop |
112 # Tell child processes to stop |
98 for i in range(NumberOfProcesses): |
113 for i in range(NumberOfProcesses): |