Skip to main content

Quiv: threadpool-backed scheduler for Python applications

Project description

quiv Logo


Python Code style: black License: MIT PyPI Pulls

Build Tests Type Check GitHub Issues GitHub last commit

quiv is a lightweight background task scheduler for Python applications.

It is designed to work especially well with FastAPI apps that need predictable, in-process background task orchestration.

Supports Python 3.10 through 3.14.

It provides:

  • threadpool-backed execution
  • support for sync and async task handlers
  • cooperative cancellation (_stop_event)
  • progress callbacks routed to your main async loop (_progress_hook)
  • persistent task/job state via SQLModel + SQLite

When to use quiv

Use quiv when you need in-process background scheduling for app-level jobs, for example:

  • polling APIs every N seconds
  • periodic cleanup tasks
  • one-shot delayed jobs
  • progress-aware long-running workloads

Install

uv add quiv
# or
pip install quiv

Quick start

from contextlib import asynccontextmanager

from fastapi import FastAPI

from quiv import Quiv

scheduler = Quiv(timezone="UTC")


def ping(_progress_hook=None):
    for i in range(30):
        # do some work
        if _progress_hook:
            _progress_hook(message="ping", progress=i, total=30)


async def on_progress(**payload):
    # Replace with websocket broadcast, logging, metrics, etc.
    print("progress", payload)


@asynccontextmanager
async def lifespan(app: FastAPI):
    # Startup
    scheduler.start()
    yield
    # Shutdown
    scheduler.shutdown()


app = FastAPI(lifespan=lifespan)

@app.post("/start-heartbeat")
def start_heartbeat():
    scheduler.add_task(
        task_name="heartbeat",
        func=ping,
        interval=30,
        progress_callback=on_progress,
    )
    return {"message": "Heartbeat started successfully!"}

Documentation

Full documentation is available at nandyalu.github.io/quiv.

License

MIT

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

quiv-0.3.5.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

quiv-0.3.5-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file quiv-0.3.5.tar.gz.

File metadata

  • Download URL: quiv-0.3.5.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for quiv-0.3.5.tar.gz
Algorithm Hash digest
SHA256 9561886f0519a83050ebd2543ea7403745f8af043e7115fb819fff3e1ef9722e
MD5 36efa9356a96283084a31cf1448307f6
BLAKE2b-256 b7d12dc75fd1112bf15a095403d3f7a7aef4fd7ce31c2020139da514cc662bf7

See more details on using hashes here.

File details

Details for the file quiv-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: quiv-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for quiv-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dede7685e033f35e455b4c6a31787d233ddfa69cd02af46ff9fc80f9d21f096b
MD5 4082481d1faa825752ab9d8c4db6a3bb
BLAKE2b-256 70de24ffcd952dcfff9f9ec5de51e509f0aecd26f3596eb6b2e9685f69586c72

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