Metadata-Version: 2.4
Name: pydovetail
Version: 3.0.0
Summary: A lightweight helper for bridging sync and async code, built on Asyncio & ThreadPoolExecutor
Author-email: anthrosystems <peaceolawuyi01@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/anthrosystems/dovetail
Project-URL: Repository, https://github.com/anthrosystems/dovetail
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typing_extensions>=4.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Requires-Dist: ruff>=0.8; extra == "dev"
Dynamic: license-file

# Dovetail

[![CI](https://github.com/anthrosystems/dovetail/actions/workflows/ci.yml/badge.svg)](https://github.com/anthrosystems/dovetail/actions/workflows/ci.yml)

Dovetail (`pydovetail`) bridges synchronous functions and `asyncio` using a
bounded thread pool. Requires **Python 3.10+**; no runtime dependencies.

```bash
python -m pip install pydovetail
```

## Quick start

```python
import asyncio
from pydovetail import Dovetail

def blocking_double(value):
    return value * 2

async def main():
    with Dovetail(max_workers=8) as dvt:
        result = await dvt.task.to_thread(blocking_double, 4)
        results = await dvt.task.map(blocking_double, range(10), max_concurrency=8)
        print(result, results)

asyncio.run(main())
```

Use `dvt.task.map_blocking(func, items, max_concurrency=8)` from synchronous
code, or `dvt.task.run_blocking(coroutine)` to bridge a synchronous caller.
Never call blocking wrappers from an already-running event loop.

## Capabilities

- `task.to_thread`: await a blocking function in the executor.
- `task.map`: ordered concurrent mapping, with `max_concurrency` and
  `return_exceptions` controls.
- `task.map_blocking`: synchronous mapping wrapper.
- `task.schedule`: schedule coroutine or callable work.
- `task.run_blocking`: bridge synchronous callers.
- Lifecycle events, counters, tracing, rate limiting, retries and timeouts.

Timeouts cannot stop already-running Python threads. Consult the
[migration and concurrency guide](docs/migration.md) for cancellation semantics
and downstream migrations.

## Reference and development

- [API reference](docs/api.md)
- [Concurrency and migration](docs/migration.md)
- [Benchmarks](docs/benchmarks.md)

Run `python -m pip install -e '.[dev]'` then `python tests/test.py`.
CI runs Python 3.10–3.14, linting, a benchmark smoke test and package builds.

MIT licensed; see [LICENSE](LICENSE).
