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