❤️ cardaio
A Python library for adjustable delays.
The main use case is when you want to periodically pull something from a third-party system but you don't know exactly how often the system will have updates. For example, you're monitoring a news website for a particular topic and you want to pull news as soon as they are available but at the same time you don't want to send too many requests when there are no updates.
😎 Features
- 🐍 Pure Python.
- 🐎 asyncio-first with synchronous API available.
- 🛡 Fully type-annotated and type-safe.
- 🪶 Zero-dependency.
- 🔧 Highly configurable.
- ☑️ 100% test coverage.
📦 Installation
python3 -m pip install cardaio
🛠️ Usage
from cardaio import Heartbeat
async def run() -> None:
hb = Heartbeat(
# never pull more often than every 1s.
fastest=1,
# never pull less often than every 1m.
slowest=60,
# start with 10s between iterations.
start=10,
)
async for _ in hb:
# Pull messages from a remote system.
msgs = await pull_messages()
# If there are more than 5 messages,
# start pulling more often.
if msgs > 5:
hb.faster()
# If there are no messages,
# pull less often
elif not msgs:
hb.slower()
... # do something with messages
🖨 Acknowledgments
The project is inspired by cardio.go Go script introduced by Xe Iaso in the Anything can be a message queue if you use it wrongly enough blog post. The implementation and API are different, though, to make it pythonic and user-friendly.
Metadata
Release files for cardaio 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cardaio-1.0.0.tar.gz | 6.6 kB | Without provenance | Details for cardaio-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cardaio-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for cardaio-1.0.0-py3-none-any.whl |
Total release size: 11.4 kB
Release files / cardaio-1.0.0.tar.gz
| Download URL | cardaio-1.0.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c749d326d68c85c859bfe2fe659ab4bcabfa8bcc0bb058b30506267e902fc57c
|
|
BLAKE2b-256 checksum How to use checksums |
48b54f402c22aedde8665674a23225fd1c3507fd4d91b8214de6f1a0634a6f36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.2
|
Release files / cardaio-1.0.0-py3-none-any.whl
| Download URL | cardaio-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3796b1ef45eacce3ebbd8f1d6c2d468f728f1c36037527f88be581652921bc5d
|
|
BLAKE2b-256 checksum How to use checksums |
07792f926cdd9d586b335d0108be52f965c8a7eb35ad54056227f0411e167ef7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.2
|
Security for cardaio 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.