python / cpython

The Python programming language
https://www.python.org
Other
62.3k stars 29.93k forks source link

Implement “Happy Eyeballs” algorithim (RFC 8305) in socket.create_connection() #88810

Open 2e0802d2-c193-4d95-9ba5-5c68cc072bfc opened 3 years ago

2e0802d2-c193-4d95-9ba5-5c68cc072bfc commented 3 years ago
BPO 44644

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['library', '3.9', 'performance'] title = 'Implement \xe2\x80\x9cHappy Eyeballs\xe2\x80\x9d algorithim (RFC 8503) in socket.create_connection()' updated_at = user = 'https://bugs.python.org/origin400-p' ``` bugs.python.org fields: ```python activity = actor = 'origin400-p' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'origin400-p' dependencies = [] files = [] hgrepos = [] issue_num = 44644 keywords = [] message_count = 1.0 messages = ['397542'] nosy_count = 1.0 nosy_names = ['origin400-p'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = 'performance' url = 'https://bugs.python.org/issue44644' versions = ['Python 3.9'] ```

2e0802d2-c193-4d95-9ba5-5c68cc072bfc commented 3 years ago

While support for the so-called “Happy Eyeballs” algorithim described in RFC 8305 was implemented for asyncio in Issue bpo-33530, socket's create_connection function remains left without it causing suboptimal performance in broken dual-stack environments.

gpshead commented 1 year ago

socket.create_connection() does indeed need this feature. In addition to our existing asyncio implementation's behavior we could also look at what Golang has done, they implemented the original rfc-6555 quite a while back and are tracking 8305 in https://github.com/golang/go/issues/23841. (even only implementing rfc-6555's variant would be a big improvement)

gpshead commented 1 year ago

It'd also be interesting if we could avoid maintaining two implementations of this in the stdlib so long as the cost to do so is not even more complicated to maintain. (ex: Would the ironic thing of socket.create_connection running its own singular asyncio event loop just for the duration of this task feasible or a Bad Idea™️ ?)