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)
Whatever our
create_connectionlooks 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:(+ the mandatory caching the RFC 6555 specifies)