Files
eveAI/eveai_workers/celery_utils.py
Josako 8e5ad5f312 Refactoring part 1
Some changes for workers, but stopped due to refactoring
2024-05-06 21:30:07 +02:00

24 lines
827 B
Python

from .tasks import create_embeddings
from celery import Celery, Task
def init_celery(app):
class ContextTask(Task):
def __call__(self, *args, **kwargs):
with app.app_context():
return self.run(*args, **kwargs)
celery_app = Celery(app.import_name, task_cls=ContextTask)
celery_app.conf.broker_url = app.config.get('CELERY_BROKER_URL')
celery_app.conf.result_backend = app.config.get('CELERY_RESULT_BACKEND')
celery_app.conf.accept_content = app.config.get('CELERY_ACCEPT_CONTENT')
celery_app.conf.task_serializer = app.config.get('CELERY_TASK_SERIALIZER')
celery_app.conf.timezone = app.config.get('CELERY_TIMEZONE')
celery_app.conf.enable_utc = app.config.get('CELERY_ENABLE_UTC')
celery_app.set_default()
app.extensions['celery'] = celery_app