Bleak Retry Connector
A connector for Bleak Clients that handles transient connection failures
Installation
Install this via pip (or your favourite package manager):
pip install bleak-retry-connector
Usage
Quick Start
Replace your direct BleakClient.connect() calls with establish_connection() for automatic retry logic and better error handling:
import asyncio
from bleak import BleakScanner
from bleak_retry_connector import establish_connection, BleakClientWithServiceCache
async def connect_to_device():
# Find your device
device = await BleakScanner.find_device_by_address("AA:BB:CC:DD:EE:FF")
if device is None:
print("Device not found!")
return
# Establish connection with automatic retry logic
client = await establish_connection(
BleakClientWithServiceCache, # Use BleakClientWithServiceCache for service caching
device,
device.name or "Unknown Device",
max_attempts=3, # Will retry up to 3 times with backoff
)
try:
# Use the connected client normally
services = client.services
print(f"Connected! Found {len(list(services))} services")
# Read a characteristic
value = await client.read_gatt_char("00002a00-0000-1000-8000-00805f9b34fb")
print(f"Read value: {value}")
finally:
await client.disconnect()
# Run the example
asyncio.run(connect_to_device())
Why Use bleak-retry-connector?
- Automatic Retry Logic: Handles transient connection failures automatically
- Intelligent Backoff: Uses appropriate delays between retry attempts
- Service Caching:
BleakClientWithServiceCachecaches services for faster reconnections - Better Error Messages: Provides clear, actionable error messages
- Platform-Specific Handling: Manages quirks across different operating systems
- Connection Slot Management: Handles limited connection slots on some devices
Common Connection Issues This Solves
- Device not found errors that resolve on retry
- Connection timeouts on first attempt
- "Out of connection slots" errors on ESP32 devices
- Interference from other Bluetooth operations
- Platform-specific connection quirks
For detailed documentation and advanced usage, see the full documentation.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
This package was created with Cookiecutter and the browniebroke/cookiecutter-pypackage project template.
Release files for bleak-retry-connector 4.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bleak_retry_connector-4.7.1.tar.gz | 19.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bleak_retry_connector-4.7.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.7 kB
Release files / bleak_retry_connector-4.7.1.tar.gz
| Download URL | bleak_retry_connector-4.7.1.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a5b07d2d7c5a9809b1769492d956604a7403870693be92754259d9eed5c177e
|
|
BLAKE2b-256 checksum How to use checksums |
758beb4a6668665f4e028a27b6036ad4816683c442158520f4ea2aad9ff775c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logRelease files / bleak_retry_connector-4.7.1-py3-none-any.whl
| Download URL | bleak_retry_connector-4.7.1-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75b4cb3f69955123121d860348d2c43da638a0f3211f2cb6197d717edbd6f47f
|
|
BLAKE2b-256 checksum How to use checksums |
90ec3b503e27e65872ac5ae213ee913b5509e461bb96b1d495ae2f72800c4a85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency log