2024-02-11 03:14:17 +03:00
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from celery import Celery
|
|
|
|
|
2024-02-12 03:03:24 +03:00
|
|
|
from fastfood.config import settings
|
|
|
|
|
2024-02-11 03:14:17 +03:00
|
|
|
from .updater import main
|
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
|
|
|
|
|
|
|
|
celery_app = Celery(
|
|
|
|
'tasks',
|
2024-02-12 03:03:24 +03:00
|
|
|
broker=settings.REBBITMQ_URL,
|
2024-02-11 03:14:17 +03:00
|
|
|
backend='rpc://',
|
|
|
|
include=['bg_tasks.bg_task'],
|
|
|
|
)
|
|
|
|
|
|
|
|
celery_app.conf.beat_schedule = {
|
|
|
|
'run-task-every-15-seconds': {
|
|
|
|
'task': 'bg_tasks.bg_task.periodic_task',
|
2024-02-12 22:22:59 +03:00
|
|
|
'schedule': 30.0,
|
2024-02-11 03:14:17 +03:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-11 20:10:25 +03:00
|
|
|
@celery_app.task
|
2024-02-11 03:14:17 +03:00
|
|
|
def periodic_task() -> None:
|
|
|
|
result = loop.run_until_complete(main())
|
|
|
|
return result
|