Skip to main content

A lightweight task scheduler for small projects

Project description

Queueing tasks in Python doesn’t have to be complicated.

Overview

simplepyq is a simple task queuing library designed for small projects that need resilient, background task execution without the overhead of tools like Celery or Airflow. It uses SQLite for persistence and supports channels for organizing tasks, retries for resilience, and a DelayException for dynamic deferral.

Installation

Install via pip:

pip install simplepyq

Usage

from simplepyq import SimplePyQ, DelayException

def scrape_url(args):
    url = args["url"]
    if "fail" in url:
        raise Exception("API failed")
    if "wait" in url:
        raise DelayException(10)
    print(f"Scraping {url}")

scheduler = SimplePyQ("tasks.db")
scheduler.add_channel("scrape", scrape_url)
scheduler.enqueue("scrape", {"url": "https://example.com"}, retries=2)
scheduler.enqueue("scrape", {"url": "https://wait.com"})
scheduler.run_until_complete()  # Or scheduler.start() for background

Features

  • Channels: Group tasks by function (e.g., “scrape”).

  • Persistence: Tasks survive restarts via SQLite.

  • Retries: Automatic retries on failure.

  • DelayException: Defer tasks dynamically.

  • Simple Setup: No external dependencies beyond msgpack.

Testing

To run the included unit tests:

python -m unittest discover -s tests

This will execute all tests in the tests/ directory and report results.

The tests cover basic task execution, retries, delays, and failed task management.

License

Apache License2.0

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

simplepyq-0.1.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

simplepyq-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file simplepyq-0.1.1.tar.gz.

File metadata

  • Download URL: simplepyq-0.1.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for simplepyq-0.1.1.tar.gz
Algorithm Hash digest
SHA256 13f450b1d7042d59678cfbcbc01e5ebada19fbfa07cd7a3f7ab6710e11f64949
MD5 a1102d0bcfc759d0c169064782ca2619
BLAKE2b-256 8cbc88d938182b68ffe77c9c801499bc9cc6a034c8e04b487be95cc2a008ef9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplepyq-0.1.1.tar.gz:

Publisher: python-publish.yml on kdewald/simplepyq

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

File details

Details for the file simplepyq-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: simplepyq-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for simplepyq-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5dfb7a5ff9d47f32ea1366d34344e506cf873be8cfb38ebca9de60ef070a4aa
MD5 ef06dc3e67fe106c517a4acf8c94c0cc
BLAKE2b-256 989d13757b327476968e6de7167ebfcf694bb97b7ce846a2ff3a0b45bf166836

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplepyq-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on kdewald/simplepyq

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