Skip to main content

A distributed background task system for Python functions

Project description

Docket is a distributed background task system for Python functions with a focus on the scheduling of future work as seamlessly and efficiently as immediate work.

PyPI - Version PyPI - Python Version GitHub main checks Codecov PyPI - License Documentation

At a glance

from datetime import datetime, timedelta, timezone

from docket import Docket


async def greet(name: str, greeting="Hello") -> None:
    print(f"{greeting}, {name} at {datetime.now()}!")


async with Docket() as docket:
    await docket.add(greet)("Jane")

    now = datetime.now(timezone.utc)
    soon = now + timedelta(seconds=3)
    await docket.add(greet, when=soon)("John", greeting="Howdy")
from docket import Docket, Worker

async with Docket() as docket:
    async with Worker(docket) as worker:
        worker.register(greet)
        await worker.run_until_finished()
Hello, Jane at 2025-03-05 13:58:21.552644!
Howdy, John at 2025-03-05 13:58:24.550773!

Check out our docs for more details, examples, and the API reference.

Why docket?

⚡️ Snappy one-way background task processing without any bloat

📅 Schedule immediate or future work seamlessly with the same interface

⏭️ Skip problematic tasks or parameters without redeploying

🌊 Purpose-built for Redis streams

🧩 Fully type-complete and type-aware for your background task functions

💉 Dependency injection like FastAPI, Typer, and FastMCP for reusable resources

Installing docket

Docket is available on PyPI under the package name pydocket. It targets Python 3.10 or above.

With uv:

uv pip install pydocket

or

uv add pydocket

With pip:

pip install pydocket

Docket requires a Redis server with Streams support (which was introduced in Redis 5.0.0). Docket is tested with:

  • Redis 6.2, 7.4, and 8.0 (standalone and cluster modes)
  • Valkey 8.0
  • In-memory backend via fakeredis for testing

For testing without Redis, use the in-memory backend:

from docket import Docket

async with Docket(name="my-docket", url="memory://my-docket") as docket:
    # Use docket normally - all operations are in-memory
    ...

See Testing with Docket for more details.

Hacking on docket

We use uv for project management, so getting set up should be as simple as cloning the repo and running:

uv sync

The to run the test suite:

pytest

We aim to maintain 100% test coverage, which is required for all PRs to docket. We believe that docket should stay small, simple, understandable, and reliable, and that begins with testing all the dusty branches and corners. This will give us the confidence to upgrade dependencies quickly and to adapt to new versions of Redis over time.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydocket-0.17.7.tar.gz (347.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydocket-0.17.7-py3-none-any.whl (94.6 kB view details)

Uploaded Python 3

File details

Details for the file pydocket-0.17.7.tar.gz.

File metadata

  • Download URL: pydocket-0.17.7.tar.gz
  • Upload date:
  • Size: 347.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydocket-0.17.7.tar.gz
Algorithm Hash digest
SHA256 5c77ec6731a167cdcb44174abf793fe63e7b6c1c1c8a799cc6ec7502b361ee77
MD5 4916a171d5fe76d8f189ed3f51be9736
BLAKE2b-256 cdb25e12dbe2acf59e4499285e8eee66e8e81b6ba2f553696d2f4ccca0a7978c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydocket-0.17.7.tar.gz:

Publisher: publish.yml on chrisguidry/docket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydocket-0.17.7-py3-none-any.whl.

File metadata

  • Download URL: pydocket-0.17.7-py3-none-any.whl
  • Upload date:
  • Size: 94.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydocket-0.17.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d1e0921ac02026c4a0140fc72a3848545f3e91e6e74c6e32c588489017c130b2
MD5 39f7c6d0d7668826d2b655a82f673274
BLAKE2b-256 c9c768f2553819965326f968375f02597d49efe71b309ba9d8fef539aeb51c48

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydocket-0.17.7-py3-none-any.whl:

Publisher: publish.yml on chrisguidry/docket

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page