Skip to main content

Python implementation of the Happy Eyeballs Algorithm described in RFC 6555.

Project description

Happy Eyeballs in Python (RFC 6555)

https://github.com/sethmlarson/rfc6555/actions/workflows/ci.yml/badge.svg https://codecov.io/gh/sethmlarson/rfc6555/branch/master/graph/badge.svg?token=Xn7oQWErjc https://img.shields.io/pypi/v/rfc6555.svg?style=flat-square

Synchronous Python implementation of the Happy Eyeballs Algorithm described in RFC 6555. Provided with a single file and dead-simple API to allow easy vendoring and integration into other projects.

Abstract

When a server’s IPv4 path and protocol are working, but the server’s IPv6 path and protocol are not working, a dual-stack client application experiences significant connection delay compared to an IPv4-only client. This is undesirable because it causes the dual- stack client to have a worse user experience. This document specifies requirements for algorithms that reduce this user-visible delay and provides an algorithm.

Installation

$ python -m pip install rfc6555

Usage

The main API for the rfc6555 module is via rfc6555.create_connection() which functions identically to socket.create_connection() with the same arguments. This function will automatically fall back on a socket.create_connection() call if RFC 6555 is not supported (for instance on platforms not capable of IPv6) or if RFC 6555 is disabled via setting rfc6555.RFC6555_ENABLED equal to False.

IMPORTANT: Caching is NOT thread-safe by default. If you require thread-safe caching one should create their own implementation of rfc6555._RFC6555CacheManager object that is thread-safe and assign an instance to rfc6555.cache.

import rfc6555
sock = rfc6555.create_connection(('www.google.com', 80), timeout=10, source_address=('::1', 0))

# This will disable the Happy Eyeballs algorithm for future
# calls to create_connection()
rfc6555.RFC6555_ENABLED = False

# Use this to set a different duration for cache entries.
rfc6555.cache.validity_duration = 10  # 10 second validity time.

# Use this to disable caching.
rfc6555.cache.enabled = False

Support

This module supports Python 2.7 or newer and supports all major platforms. Additionally if you have selectors2>=2.0.0 installed this module will also support Jython in addition to CPython.

License

The rfc6555 package is released under the Apache-2.0 license.

See full license text in LICENSE file for more information.

Changelog

0.1.0

  • Use selectors instead of selectors2 for Python 3.5+

  • Dropped support for Python 2.6, 3.3, and 3.4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfc6555-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

rfc6555-0.1.0-py2.py3-none-any.whl (10.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rfc6555-0.1.0.tar.gz.

File metadata

  • Download URL: rfc6555-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0rc2+

File hashes

Hashes for rfc6555-0.1.0.tar.gz
Algorithm Hash digest
SHA256 123905b8f68e2bec0c15f321998a262b27e2eaadea29a28bd270021ada411b67
MD5 99fd2e4f638151275c9874af18ddc4df
BLAKE2b-256 f64b24f953c3682c134e4d0f83c7be5ede44c6c653f7d2c0b06ebb3b117f005a

See more details on using hashes here.

File details

Details for the file rfc6555-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: rfc6555-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0rc2+

File hashes

Hashes for rfc6555-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a9638af14b3aab41c9137900be8e7e9200039d44ed91408d6aef69b7dd5329da
MD5 9e322968513e2381b1d4a2f7f387a46c
BLAKE2b-256 c5e2abacd204a910234ecae3134fd84fce75e3f346277e92a508eb963c18b764

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page