Metadata-Version: 2.4
Name: simplepyq
Version: 0.1.1
Summary: A lightweight task scheduler for small projects
Home-page: https://github.com/kdewald/simplepyq
Author: Kevin Dewald
Author-email: kevin@dewald.me
License: Apache-2.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: msgpack
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

==========
simplepyq
==========

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:

.. code-block:: bash

    pip install simplepyq

Usage
-----

.. code-block:: python

    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:

.. code-block:: bash

    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
