quesadilla
quesadilla
is an elegant background task queue for the more civilized age.
Example usage
First, install quesadilla
: pip install quesadilla==0.5.0
.
tasks.py
:
import logging
import random
from quesadilla.connectors.in_memory import ThreadSafeInMemoryConnector
from quesadilla.core import TaskNamespace, async_task, sync_task
logging.basicConfig(level=logging.INFO)
namespace = TaskNamespace("tasks", connector=ThreadSafeInMemoryConnector())
queue = namespace.queue("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
for _ in range(100):
simple_task.queue(random.choice((0, 1)))
simple_atask.queue(random.choice((0, 1)))
Run with python -m quesadilla runners listener tasks::queue
.
Exit with SIGINT
(Ctrl + C) or SIGTERM
.
Roadmap
- support for retrying failed tasks
- support for cronjobs and heartbeat
- support for task priority
- support for delayed execution
- documentation
- a real-world connector! (most likely PostgreSQL with
psycopg
and SQLAlchemy 2.0
)