Refactoring part 1

Some changes for workers, but stopped due to refactoring
This commit is contained in:
Josako
2024-05-06 21:30:07 +02:00
parent d925477e68
commit 8e5ad5f312
34 changed files with 193 additions and 109 deletions

View File

@@ -0,0 +1,23 @@
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