A lightweight solution for long-running tasks
Project description
lilota
lilota is a lightweight Python library for running long-running tasks in the background without the complexity of full task queue systems like Celery or RabbitMQ.
It is designed for simple, asynchronous task execution with minimal setup and overhead.
Features
- Run long-running tasks in separate processes
- Simple API and minimal configuration
- Persistent task state stored in a database
- No message broker required
- Suitable for web applications and background jobs
When to use lilota
Use lilota when your application needs to run tasks that take time, such as:
- image or file processing
- report generation
- sending emails
- heavy computations
Instead of blocking the request, lilota lets you start the task in the background and immediately return a response to the user.
Installation
pip install lilota
Quick example
Define input and output models
from dataclasses import dataclass
@dataclass
class AddInput:
a: int
b: int
@dataclass
class AddOutput:
sum: int
Create a lilota instance
from lilota import Lilota
lilota = Lilota(
name="My Server",
db_url="postgresql+psycopg://postgres:postgres@localhost:5432/lilota_sample"
)
Register a background task
@lilota.register("add", input_model=AddInput, output_model=AddOutput)
def add(data: AddInput) -> AddOutput:
return AddOutput(sum=data.a + data.b)
Start lilota
lilota.start()
Schedule a task
task_id = lilota.schedule("add", AddInput(a=2, b=3))
Task persistence
schedule will directly execute our function in a separate process. Information about the executed task are stored inside the database in the task table. Is consits of the following columns:
| Columns | Notes |
|---|---|
| id | Primary key |
| name | Task name |
| pid | Process ID |
| status | pending, running, completed, failed, cancelled |
| progress_percentage | Progress (0-100) |
| start_date_time | Start timestamp |
| end_date_time | End timestamp |
| input | Serialized input data |
| output | Serialized output data |
| exception | Exception details if the task fails |
Shutdown
lilota.stop()
lilota will wait for running tasks to finish before exiting.
License
MIT
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 lilota-0.1.0.tar.gz.
File metadata
- Download URL: lilota-0.1.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3798cb2109f2892a8ea90bbfc1ed0ab6b3e34a04ce18172762176a7e9cffcdc4
|
|
| MD5 |
67e3f408f7e63b442e7346148cf9a82b
|
|
| BLAKE2b-256 |
4f6eaeb32f9195067d4d0acfb354097a36d4780e5cb634a6e406d553fc085ef1
|
File details
Details for the file lilota-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lilota-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5588ec1cdf60fed05ed4047a02d0d710776cb1181abc30d38cc070b2b1c3867
|
|
| MD5 |
c9860ba1884d5b49d2317a7ed050b7b9
|
|
| BLAKE2b-256 |
22fd14a66ca5810ab891c54d1bea7661cae7ddfe1f8132d6afdf0217a6d82a31
|