fastfood/bg_tasks/bg_task.py

29 lines
504 B
Python
Raw Normal View History

import asyncio
from celery import Celery
from .updater import main
loop = asyncio.get_event_loop()
celery_app = Celery(
'tasks',
2024-02-12 01:11:00 +03:00
broker='amqp://guest:guest@rabbitmq',
backend='rpc://',
include=['bg_tasks.bg_task'],
)
celery_app.conf.beat_schedule = {
'run-task-every-15-seconds': {
'task': 'bg_tasks.bg_task.periodic_task',
'schedule': 15.0,
},
}
@celery_app.task
def periodic_task() -> None:
result = loop.run_until_complete(main())
return result