Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

happy eyeballs #18

Closed
njsmith opened this issue Jan 22, 2017 · 1 comment
Closed

happy eyeballs #18

njsmith opened this issue Jan 22, 2017 · 1 comment
Labels

Comments

@njsmith
Copy link
Member

njsmith commented Jan 22, 2017

Whatever our create_connection looks like (#8), it'd be neat if it automatically did happy eyeballs :-). This should be pretty trivial (though it'd help if #7 was sorted), basically something like:

async def create_connection(host, port):
    first_family = None
    results = await getaddrinfo(...)
    # pick the first two results with different AF_* settings
    first_res = results[0]
    second_res = [res for res in results if res[0] != first_res[0]][0]
    async def connect1():
        return await connect_to(first_res)
    async def connect2():
        await trio.sleep(0.300)
        return await connect_to(second_res)
    # 'race' runs several tasks, returns the one that finishes first, and cancels the others
    return await race(connect1, connect2)

(+ the mandatory caching the RFC 6555 specifies)

@njsmith njsmith added the polish label Jan 22, 2017
@njsmith
Copy link
Member Author

njsmith commented Aug 19, 2017

Fixed by #145

@njsmith njsmith closed this as completed Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant