Refactoring part 1
Some changes for workers, but stopped due to refactoring
This commit is contained in:
23
eveai_workers/celery_utils.py
Normal file
23
eveai_workers/celery_utils.py
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user