You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement “Happy Eyeballs” algorithim (RFC 8305) in socket.create_connection() #88810
3.13only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytopic-socketRelated to the socket, socketserver and selectors modulestype-featureA feature request or enhancement
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.
changed the title [-]Implement “Happy Eyeballs” algorithim (RFC 8503) in socket.create_connection()[/-][+]Implement “Happy Eyeballs” algorithim (RFC 8305) in socket.create_connection()[/+]on May 26, 2023
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 golang/go#23841. (even only implementing rfc-6555's variant would be a big improvement)
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™️ ?)
@graingert Is your last comment implying that there already exists an implementation which could simply be copied into socket.py?
If there is no implementation yet I might have a go at implementing one. Would a patch to update create_connection in socket.py be accepted if the code is of good quality?
A few questions:
Would there have to be a setting to switch RFC 8305 behavior on/off, or can it be on always?
Would an implementation which still calls getaddrinfo and only implements the remaining parts of RFC 8305 be welcome?
Can other of the advanced features be left out in order to more quickly finalize an implementation of the most needed parts of the RFC?
Which API should be used for waiting for connections? I know epoll is preferred in some environments, but other alternatives may be more portable.
Does an implementation need to include any additional workarounds for legacy sites such as github, or is acceptable that you still can't reach such sites with create_connection from an IPv6-only network?
3.13only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytopic-socketRelated to the socket, socketserver and selectors modulestype-featureA feature request or enhancement
Activity
origin400-p commentedon Jul 15, 2021
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.
[-]Implement “Happy Eyeballs” algorithim (RFC 8503) in socket.create_connection()[/-][+]Implement “Happy Eyeballs” algorithim (RFC 8305) in socket.create_connection()[/+]gpshead commentedon May 26, 2023
socket.create_connection()does indeed need this feature. In addition to our existingasyncioimplementation'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 golang/go#23841. (even only implementing rfc-6555's variant would be a big improvement)gpshead commentedon May 26, 2023
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™️ ?)
graingert commentedon Dec 12, 2024
@gpshead this would then break users that use create_connection inside an existing asyncio event loop
graingert commentedon Dec 12, 2024
@sethmlarson has a sync implementation of happy eyeballs, it might be an idea to land that in cpython
intempus-kasperd commentedon Feb 11, 2026
@graingert Is your last comment implying that there already exists an implementation which could simply be copied into socket.py?
If there is no implementation yet I might have a go at implementing one. Would a patch to update create_connection in socket.py be accepted if the code is of good quality?
A few questions:
Studio: race address families on sync connects (RFC 8305 Happy Eyeballs)
Studio: race address families on sync connects (RFC 8305 Happy Eyebal…