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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2fba6766cad08ddf6d542e6f54a4cda5542edc177ab00f9546639ecb407b725
|
|
| MD5 |
a7cead70e965622c5f11b8c07fe6916b
|
|
| BLAKE2b-256 |
389f5fe7466f59a39ebc546ba938c345de913e3fdcd655e05bf528722795d5da
|
Provenance
The following attestation bundles were made for simplepyq-0.1.0.tar.gz:
Publisher:
python-publish.yml on kdewald/simplepyq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simplepyq-0.1.0.tar.gz -
Subject digest:
e2fba6766cad08ddf6d542e6f54a4cda5542edc177ab00f9546639ecb407b725 - Sigstore transparency entry: 188759103
- Sigstore integration time:
-
Permalink:
kdewald/simplepyq@476cb9f6df1d43ea0b3a1376d4b0adbfbd83e342 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kdewald
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@476cb9f6df1d43ea0b3a1376d4b0adbfbd83e342 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b78116e249fefa350feb5b9a90750ff55449391b9ea7a5247f63097557ca2bf
|
|
| MD5 |
c4febee357d99c8e8f991cb5219f0d95
|
|
| BLAKE2b-256 |
e0e7b7805b82e9a26677a771595668961743bb9d12ccf512c8a678b01aaced39
|
Provenance
The following attestation bundles were made for simplepyq-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on kdewald/simplepyq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simplepyq-0.1.0-py3-none-any.whl -
Subject digest:
8b78116e249fefa350feb5b9a90750ff55449391b9ea7a5247f63097557ca2bf - Sigstore transparency entry: 188759109
- Sigstore integration time:
-
Permalink:
kdewald/simplepyq@476cb9f6df1d43ea0b3a1376d4b0adbfbd83e342 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kdewald
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@476cb9f6df1d43ea0b3a1376d4b0adbfbd83e342 -
Trigger Event:
workflow_dispatch
-
Statement type: