Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Add an API to do combine Future.wait_any() with yield #135

Open
GoogleCodeExporter opened this issue Jun 10, 2015 · 1 comment
Open

Add an API to do combine Future.wait_any() with yield #135

GoogleCodeExporter opened this issue Jun 10, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Use case: wait for the first of several urls to complete. E.g.

futures = [ctx.urlfetch(u) for u in urls]
while futures:
    result = yield tasklets.first_available(futures)
    if result.status_code == 200:
        raise tasklets.Return(result.content)
    futures = [f for f in futures
               if not f.done() or f.get_result() is not result]

Hm, the API should make the awkward removal of the selected Future unnecessary 
as well.

Original issue reported on code.google.com by guido@google.com on 13 Jan 2012 at 12:26

@rknLA
Copy link

rknLA commented Oct 21, 2015

+1. Is there any way to do this right now?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants