aiohappyeyeballs

Happy Eyeballs (RFC 8305) connection racing for asyncio when you already have resolved addresses

Library
PyPI
v2.7.1
45stars
PSF-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
64/100Good
Development Activity80
Maintenance84
Community24
Maturity48
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture75
Code Quality78
Innovation70
Learning Curve80

aiohappyeyeballs implements the Happy Eyeballs algorithm (RFC 8305) for Python’s asyncio, letting you race TCP connection attempts across a pre-resolved list of addrinfo tuples instead of a DNS name. This matters for applications that already resolve names themselves — through DNS caching, custom resolvers, or service discovery like zeroconf — where the stdlib’s loop.create_connection() only accepts an unresolved hostname and can’t take advantage of dual-stack racing.

It is a small, dependency-free utility extracted from aiohttp’s internals so any asyncio-based client can reuse the same battle-tested connection racing logic without depending on aiohttp itself.

What You Get

  • A start_connection() coroutine that races connection attempts across a list of addrinfo tuples and returns the first successful socket
  • A staggered_race()-based interleaving implementation (_staggered.py) that starts connection attempts to alternating address families with a configurable delay
  • Helper functions (addr_to_addr_infos, remove_addr_infos, pop_addr_infos_interleave) for building and filtering addrinfo lists
  • Fully typed, dependency-free package (ships a py.typed marker) that works alongside loop.create_connection()

Common Use Cases

  • HTTP clients (aiohttp itself, and others) that resolve DNS themselves and want dual-stack connection racing
  • Applications using service discovery (e.g. zeroconf) that hand asyncio a list of addresses instead of a hostname
  • Custom asyncio clients that cache DNS results and need to retry/interleave among multiple resolved addresses efficiently

Under The Hood

Architecture: The package is a thin, focused layer over asyncio’s low-level socket APIs. impl.py exposes start_connection(), the public entry point, which normalizes the addrinfo list, opens a socket per candidate, and delegates interleaved racing to _staggered.staggered_race() in _staggered.py. That module runs each connection attempt as a task, starting the next candidate after happy_eyeballs_delay seconds if the previous one hasn’t completed, and cancels the losers once a winner connects — implementing RFC 8305 section 5’s staggered connection attempts. utils.py provides pure helper functions for reshaping addrinfo tuples (family/type/proto/canonname/sockaddr) between formats. types.py defines the shared AddrInfoType/SocketFactoryType type aliases used across the package.

Tech Stack: Pure Python 3.10+ with zero runtime dependencies, built with Poetry (poetry-core backend). Dev tooling is Ruff (lint, including flake8-bandit/bugbear/docstrings rule sets), mypy in strict mode (disallow_untyped_defs, disallow_any_generics), pytest with pytest-asyncio and pytest-cov, and pytest-codspeed for benchmarking. Docs are built with Sphinx/MyST/Furo and published to Read the Docs; releases are cut via python-semantic-release from Conventional Commits.

Code Quality: The tests/ directory has one test module per source file (test_impl.py, test_staggered.py, test_staggered_cpython.py, test_utils.py, test_init.py) plus a CPython-parity test (test_staggered_cpython_eager_task_factory.py) that checks behavior against the upstream asyncio implementation under eager task factories — a strong signal of deliberate compatibility testing. Coverage is enforced via --cov=aiohappyeyeballs --cov-report=term-missing:skip-covered in pytest config, and mypy strict mode plus Ruff’s bandit ruleset catch type and security issues before merge.

API Design: The public surface is intentionally minimal — one coroutine (start_connection) plus three small helpers, all re-exported from the package __init__.py. Docstrings on start_connection spell out every parameter and show the exact loop.create_connection() composition pattern, so adopting it requires no more than swapping a DNS-name argument for a pre-fetched addrinfo list.

Used by 7 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
Python
63%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,039

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
88
Repo Health
91
Technical
64
Dependency
Built with
Python63%
TypeScript23%
Updated 1 months ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
Python
83%
Apache 2.0

knowhere

AI Development · Developer Tools

2,515

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
70
Dependency
Built with
Python83%
HTML16%
Updated today
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today
Python
94%
Apache 2.0

SWIRL

Search · Databases · Data Engineering

3,039

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
77
Repo Health
83
Technical
65
Dependency
Built with
Python94%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search