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.2.4.tar.gz (15.0 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.2.4-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quiv-0.2.4.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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.2.4.tar.gz
Algorithm Hash digest
SHA256 e369b1aaeafca4d55ad16de82a3d0c38f53ad1fa763fd39ad2c35229070f2bcb
MD5 107d46725ac5fe39ba9f7d5bf68276b1
BLAKE2b-256 9c451ca3fdd292fab6843c52747f3b3bd3c1c8b7d7dbb01d2c11bf6fab1611af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quiv-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","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.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8cd8424acbbb9d515a4a9a86cebf603eedeb03e98f05046dbc522243b6677abd
MD5 1bcd3f93b5111fafa1cf202f06a095cb
BLAKE2b-256 a23452b7daf9e1e0270ccbae8018c3d3d5eece5d3f0e6220884e8ac762c9a6a0

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