Celery Periodic Tasks backed by the sqlmodel
Project description
Database backed Celery Beat Scheduler
Description
This is an sqlmodel based implementation of the celery beat scheduler. It persists periodic celery tasks in a SQLAlchemy-compatible database.
Usage
You can install this package using pip.
After installation, specify the database connection string in the Celery config, using the name beat_dburi
. Modified
from sqlmodel-celery-beat to support pydantic v2. and optimize some functions
You can run the beat instance using:
install
pip install celery-sqlmodel-beat
tasks.py
from celery import Celery
from sqlmodel_celery_beat.schedulers import ( # pylint: disable=unused-import
DatabaseScheduler,
)
beat_scheduler = "sqlmodel_celery_beat.schedulers:DatabaseScheduler"
beat_dburi = 'sqlite:///schedule.db'
# beat_dburi = 'mysql+mysqlconnector://root:root@127.0.0.1/celery-schedule'
config = {
"broker_url": "redis://:127.0.0.1:6379/1",
"result_backend": "redis://:127.0.0.1:6379/2",
"beat_dburi": beat_dburi,
}
celery = Celery(__name__)
celery.config_from_object(config)
celery.autodiscover_tasks()
@celery.task(name='tasks.add')
def add(x, y):
return x + y
Run Celery
celery -A tasks:celery worker -l info
celery -A tasks:celery beat -S tasks:DatabaseScheduler -l info
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
Built Distribution
File details
Details for the file celery_sqlmodel_beat-0.1.4.tar.gz
.
File metadata
- Download URL: celery_sqlmodel_beat-0.1.4.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60afe86c54a8a30664e82c3fffacd9ad0fd2598ac47864e4cd4630b89b689b93 |
|
MD5 | 7e0af0388b28551c11297181d4159682 |
|
BLAKE2b-256 | b694489107002cf980bcf36c182b3070c1e6e95b91a2a151bfd08c83805dbc38 |
File details
Details for the file celery_sqlmodel_beat-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: celery_sqlmodel_beat-0.1.4-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 485c4b8f30acb0ed1d867889ab17adba9f932c6dbf4b9e27bb8b9eb8859ee760 |
|
MD5 | 90643fd8147688a45e1c021943ea01c0 |
|
BLAKE2b-256 | b125097ec228bf3b8c0123eeb14a3894fa095196da514acbc8aa249e2edf1d19 |