Skip to main content

An elegant background task queue for the more civilized age

Project description

pipeline status coverage report latest release

quesadilla

quesadilla is an elegant background task queue for the more civilized age.

Example usage

First, install the basic metapackage: pip install quesadilla==0.2.0.

tasks.py

import logging

from quesadilla.connectors.in_memory import ThreadSafeInMemoryConnector
from quesadilla.shortcuts import async_task, sync_task, TaskNamespace, QueuedTask
from quesadilla.runners import MultithreadingRunner, RunnerConfig

logging.basicConfig(level=logging.INFO)

namespace = TaskNamespace(
    "quesadilla.examples.simple",
    connector=ThreadSafeInMemoryConnector(),
)
queue = namespace.new("queue")


@sync_task(queue)
def simple_task(i: int) -> bool:
    return i == 0


@async_task(queue)
async def simple_atask(i: int) -> bool:
    return i == 0


tasks: list[QueuedTask[[int], bool]] = []


# queue is preloaded with 200 tasks
for _ in range(100):
    tasks.append(simple_task.queue(0))
    tasks.append(simple_atask.queue(1))


if __name__ == "__main__":
    runner = MultithreadingRunner(queue, config=RunnerConfig(brokers=2, workers=5))
    with runner:
        for task in tasks:
            task.wait_for()

    # runner will automatically shut down and clean up when all tasks are done

Run with python -m quesadilla runners listener tasks::queue.

Roadmap

  • support for retrying failed tasks
  • support for cronjobs and heartbeat
  • support for task priority
  • support for delayed execution
  • documentation
  • sync and async connectors split (probably)
  • a real-world connector! (most likely PostgreSQL with psycopg and SQLAlchemy 2.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

quesadilla-0.2.0.tar.gz (16.0 kB view hashes)

Uploaded Source

Built Distribution

quesadilla-0.2.0-py3-none-any.whl (19.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page