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, gvanrossum, pitrou, vstinner
Date 2014-02-08.20:18:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391890694.33.0.714223329819.issue20566@psf.upfronthosting.co.za>
In-reply-to
Content
In asyncio, tasks.py as_completed() appears to trigger adding and removing callbacks multiple times for the pending set of futures, each time a single future completes. 

For example, to wait for 5 futures which complete at different times:
- as_completed() uses _wait()
- _wait() will add 5 callbacks, one for each future
- when one future completes, a callback is triggered and all 5 callbacks are removed; this is because _wait() was called with FIRST_COMPLETED
- for the 4 remaining futures - 4 callbacks have to be added back again
- when the next future completes, the 4 callbacks are removed
etc…

The worst case is if as_completed() is called to wait for all of a larger number of futures, which complete at different times. For example, with 100 futures worst case, ~10,000 callback adds and removes would be performed.

(I am very new to the asyncio code, so I don't have a patch to offer at this point).
History
Date User Action Args
2014-02-08 20:18:14glangfordsetrecipients: + glangford, gvanrossum, pitrou, vstinner
2014-02-08 20:18:14glangfordsetmessageid: <1391890694.33.0.714223329819.issue20566@psf.upfronthosting.co.za>
2014-02-08 20:18:14glangfordlinkissue20566 messages
2014-02-08 20:18:13glangfordcreate