Metadata-Version: 2.4
Name: simple-q-runtime
Version: 1.3.0
Requires-Dist: prometheus-client>=0.26
Summary: Queue runtime for Python async tasks, with a Rust extension for Redis enqueue and locks
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/hewimetall/simple-redis-q
Project-URL: Issues, https://github.com/hewimetall/simple-redis-q/issues
Project-URL: Repository, https://github.com/hewimetall/simple-redis-q

# simple-q

Rust supervisor and queue runtime for Python async tasks. The worker binary is `agent-worker`. Application code imports `simple_q`. The Rust extension inside that package is `simple_q._runtime`.

## Install

Supported runtime: CPython 3.12, 3.13, 3.14, and 3.15 with the GIL. Linux x86_64 and aarch64, glibc 2.28 or newer. Free-threaded builds are not supported. A producer and a worker may use different minor versions: the message is JSON, and the actor module is imported by the worker.

```bash
uv add simple-q-runtime simple-q-worker
```

`simple-q-runtime` is the importable package (`import simple_q`). `simple-q-worker` installs the `agent-worker` binary into the virtualenv and depends on the same version of `simple-q-runtime`.

A local macOS producer is `maturin develop` against CPython 3.12 or newer. A local worker is `cargo build -p agent-worker` with `PYO3_PYTHON` pointing at a shared CPython (`libpython3.X.dylib` from python.org or Homebrew). PyO3 sets the rpath. Published wheels and the `agent-worker` launcher are Linux.

## Example

```python
from simple_q import App, Client, Config, actor


@actor(queue="default", max_retries=2, lock_key="demo:gate")
async def recalc(project_id: int) -> None:
    ...


def create_app() -> App:
    config = Config.from_env()
    return App(client=Client("redis://redis:6379/0", config=config), actors=[recalc])


async def enqueue() -> None:
    config = Config.from_env()
    client = Client("redis://redis:6379/0", config=config)
    await client.send_with_options(
        recalc,
        kwargs={"project_id": 42},
        unique_key="recalc:42",
    )
    await client.close()
```

## Documentation

These pages describe main, package 1.3.0: [docs/index.md](docs/index.md). The running worker is `agent-worker` and `simple-q-runtime`. A research example of a later fork is under `docs/research/example` and is not part of the build.

