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): |