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.

classification
Title: concurrent.futures.as_completed() spins waiting for futures to complete
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bquinlan Nosy List: bquinlan, georg.brandl, scott.dial
Priority: normal Keywords: patch

Created on 2010-11-16 10:59 by scott.dial, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
futures-r86476.patch scott.dial, 2010-11-16 10:59 proposed patch against r86476
Messages (4)
msg121280 - (view) Author: Scott Dial (scott.dial) Date: 2010-11-16 10:59
The code in as_completed() waits on a FIRST_COMPLETED event, which means that after the first future completes, it will no longer wait at all. The proposed patch adds a _AsCompletedWaiter and uses a lock to swap out the finished list and reset the event.

This is a difficult problem to create a test case for without adding intrusive code to as_completed() to count how many times it loops or create a mock Event object that counts it, so I have not proposed a test.
msg121344 - (view) Author: Brian Quinlan (bquinlan) * (Python committer) Date: 2010-11-17 11:08
Looks good but you forgot to actually use your new Waiter ;-)

Committed as r86491.
msg121345 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-11-17 11:09
Please mention the issue number in the commit message when applying patches or bugfixes.
msg121347 - (view) Author: Scott Dial (scott.dial) Date: 2010-11-17 11:29
Good catch. I suppose it was inevitable when I transferred my changes into a SVN checkout that I missed something. Nevertheless, your changeset in r86491 matches my own. Thanks!
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54641
2010-11-17 11:29:53scott.dialsetmessages: + msg121347
2010-11-17 11:09:36georg.brandlsetnosy: + georg.brandl
messages: + msg121345
2010-11-17 11:08:12bquinlansetstatus: open -> closed
resolution: fixed
messages: + msg121344

stage: patch review -> resolved
2010-11-16 11:52:44orsenthilsetassignee: bquinlan
stage: patch review

nosy: + bquinlan
versions: - Python 3.3
2010-11-16 10:59:34scott.dialcreate