Iterate on the list *fs*, yielding finished futures one by one in reverse order. Before yielding a future, *waiter* is removed from its waiters and the future is removed from each set in the collection of sets *ref_collect*. The aim of this function is to avoid keeping stal
(fs, waiter, ref_collect)
| 175 | |
| 176 | |
| 177 | def _yield_finished_futures(fs, waiter, ref_collect): |
| 178 | """ |
| 179 | Iterate on the list *fs*, yielding finished futures one by one in |
| 180 | reverse order. |
| 181 | Before yielding a future, *waiter* is removed from its waiters |
| 182 | and the future is removed from each set in the collection of sets |
| 183 | *ref_collect*. |
| 184 | |
| 185 | The aim of this function is to avoid keeping stale references after |
| 186 | the future is yielded and before the iterator resumes. |
| 187 | """ |
| 188 | while fs: |
| 189 | f = fs[-1] |
| 190 | for futures_set in ref_collect: |
| 191 | futures_set.remove(f) |
| 192 | with f._condition: |
| 193 | f._waiters.remove(waiter) |
| 194 | del f |
| 195 | # Careful not to keep a reference to the popped value |
| 196 | yield fs.pop() |
| 197 | |
| 198 | |
| 199 | def as_completed(fs, timeout=None): |
no test coverage detected