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.0.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.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simplepyq-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e2fba6766cad08ddf6d542e6f54a4cda5542edc177ab00f9546639ecb407b725
MD5 a7cead70e965622c5f11b8c07fe6916b
BLAKE2b-256 389f5fe7466f59a39ebc546ba938c345de913e3fdcd655e05bf528722795d5da

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplepyq-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: simplepyq-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b78116e249fefa350feb5b9a90750ff55449391b9ea7a5247f63097557ca2bf
MD5 c4febee357d99c8e8f991cb5219f0d95
BLAKE2b-256 e0e7b7805b82e9a26677a771595668961743bb9d12ccf512c8a678b01aaced39

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplepyq-0.1.0-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