Dovetail
Dovetail (pydovetail) bridges blocking Python functions and asyncio with
an owned ThreadPoolExecutor, task lifecycle events, retries, rate limits,
and optional tracing.
Requires Python 3.10+ and typing_extensions>=4.0 (for Self on Python 3.10).
python -m pip install pydovetail
Quick start
import asyncio
from pydovetail import Dovetail
def blocking_double(value: int) -> int:
return value * 2
async def main() -> None:
async with Dovetail(max_workers=8) as dvt:
value = await dvt.task.to_thread(blocking_double, 4)
values = await dvt.task.map(
blocking_double, range(10), max_concurrency=8
)
print(value, values)
asyncio.run(main())
From synchronous code, use dvt.task.to_thread_blocking(...),
dvt.task.map_blocking(...), or dvt.task.run_blocking(...). Never invoke
these blocking wrappers inside a running event loop.
Features
- Blocking work:
await dvt.task.to_thread(func, *args, **kwargs). - Bounded ordered mapping:
await dvt.task.map(func, items, max_concurrency=8, return_exceptions=False); the mapped function must be synchronous. - Scheduling:
dvt.task.schedule(coroutine_or_callable, ...)returns anasyncio.Task;dvt.task.managed()wraps sync and async functions. - Observability:
dvt.events.on(...),dvt.events.stats(), custom counters, and optional tracing. - Execution policy: per-instance timeout, retries, retry backoff and rate limiting for supported execution paths.
- Lifecycle: sync and async context managers, explicit
shutdown(), and an optional weak-reference instance registry.
Cancellation matters: a timeout or cancellation of an awaiter cannot stop
an already-running Python thread. Its side effects may continue. Retry backoff
also occupies a worker thread. Use a bounded concurrency setting and make
blocking operations idempotent where possible. Coroutine scheduling and
blocking-function mapping are different APIs: do not pass async def
functions to task.map().
For exact signatures, event behaviour, and shutdown semantics, see the API reference. For reproducible performance experiments, see Benchmarks.
Development
python -m pip install -e ".[dev]"
python tests/test.py # legacy feature suite
python -m pytest tests/ -v # pytest-discoverable tests
python -m ruff check .
python -m build
python -m twine check dist/*
The CI matrix targets Python 3.10–3.14. Passing the matrix does not imply that all multi-instance shutdown and cancellation edge cases are covered.
MIT licensed; see LICENSE.
Metadata
Release files for pydovetail 3.0.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 | Provenance | Actions |
|---|---|---|---|---|
| pydovetail-3.0.1.tar.gz | 30.7 kB | With provenance | Details for pydovetail-3.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydovetail-3.0.1-py3-none-any.whl | Python 3 | none | any | Details for pydovetail-3.0.1-py3-none-any.whl |
Total release size: 52.5 kB
Release files / pydovetail-3.0.1.tar.gz
| Download URL | pydovetail-3.0.1.tar.gz |
|---|---|
| Size | 30.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e61195151af57228f55ffa157bb0d3f39859fe137668f96bd376fbd7e05a883
|
|
BLAKE2b-256 checksum How to use checksums |
9b3ab5dbdf8f5bbe35eaf9e894fa7c1721ce0dd9c1e8962530eb333c236eebcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 1, 2026.
Transparency logRelease files / pydovetail-3.0.1-py3-none-any.whl
| Download URL | pydovetail-3.0.1-py3-none-any.whl |
|---|---|
| Size | 21.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb5ced6b5d9390cb83dca413ec621bc6c18cc1a178e77770010b30133a67e073
|
|
BLAKE2b-256 checksum How to use checksums |
92d527202768972684ee23e25ae7b176857acdcce8b264f75c9bac042367fc3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 1, 2026.
Transparency logSecurity for pydovetail 3.0.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pydovetail-3.0.1.tar.gz
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 Nov 1, 2026.
Transparency logA 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.