This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author glangford
Recipients glangford
Date 2014-01-18.21:19:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:35glangfordsetrecipients: + glangford
2014-01-18 21:19:35glangfordsetmessageid: <>
2014-01-18 21:19:35glangfordlinkissue20297 messages
2014-01-18 21:19:35glangfordcreate