Message208418
as_completed() calls _create_and_install_waiters() over all given Futures, even if some (or all) of the Futures have already completed.
The following fragment of the as_completed code (from 3.3.3):
with _AcquireFutures(fs):
finished = set(
f for f in fs
if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
pending = set(fs) - finished
waiter = _create_and_install_waiters(fs, _AS_COMPLETED)
installs waiters into Futures contained in fs, rather than pending.
A more efficient approach might be to only install waiters on the pending subset if necessary. This would be faster and would also result in less dwell time with all of the Future conditions locked via the _AcquireFutures context manager.
Also: waiters are appended with the Future condition lock acquired, but are removed (at the conclusion of as_completed) without the _AcquireFutures condition lock. Is this correct? |
|
Date |
User |
Action |
Args |
2014-01-18 21:19:35 | glangford | set | recipients:
+ glangford |
2014-01-18 21:19:35 | glangford | set | messageid: <1390079975.89.0.167689725202.issue20297@psf.upfronthosting.co.za> |
2014-01-18 21:19:35 | glangford | link | issue20297 messages |
2014-01-18 21:19:35 | glangford | create | |
|