Skip to main content

distributed background task system for python functions

Project description

Shadow 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 shadows import Shadow


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


async with Shadow() as shadows:
    await shadows.add(greet)("Jane")

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

async with Shadow() as shadows:
    async with Worker(shadows) as worker:
        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 shadows?

⚡️ 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 shadows

Shadow is available on PyPI under the package name shadow-task. It targets Python 3.12 or above.

With uv:

uv pip install shadows

or

uv add shadows

With pip:

pip install shadows

Shadow requires a Redis server with Streams support (which was introduced in Redis 5.0.0). Shadow is tested with Redis 6 and 7.

Hacking on shadows

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 shadows. We believe that shadows 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


Download files

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

Source Distribution

shadow_task-0.1.0.tar.gz (135.3 kB view details)

Uploaded Source

File details

Details for the file shadow_task-0.1.0.tar.gz.

File metadata

  • Download URL: shadow_task-0.1.0.tar.gz
  • Upload date:
  • Size: 135.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for shadow_task-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22eff4405df64ea9351a6db07e569c36ec395f3cb63f51e0334a26c905a130c0
MD5 fd3f8b0e96cb60664d97b38ee901d306
BLAKE2b-256 8bb931440498e852f249ed0ac86bf2c5549c086ea2eadc7c34dece3d528fe2d0

See more details on using hashes here.

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