Refactoring finished :-)
eveai_workers now working (with errors ;-) ) Remote debugging now available
This commit is contained in:
@@ -1,21 +1,30 @@
|
||||
from celery import Celery
|
||||
from kombu import Queue
|
||||
from werkzeug.local import LocalProxy
|
||||
|
||||
celery_app = Celery()
|
||||
|
||||
|
||||
def init_celery(celery, app):
|
||||
celery_app.main = app.name
|
||||
celery_config = {
|
||||
'broker_url': app.config.get('CELERY_BROKER_URL', 'redis://localhost:6379/0'),
|
||||
'result_backend': app.config.get('CELERY_RESULT_BACKEND', 'redis://localhost:6379/0'),
|
||||
'task_serializer': app.config.get('CELERY_TASK_SERIALIZER', 'json'),
|
||||
'result_serializer': app.config.get('CELERY_RESULT_SERIALIZER', 'json'),
|
||||
'accept_content': app.config.get('CELERY_ACCEPT_CONTENT', ['json']),
|
||||
'timezone': app.config.get('CELERY_TIMEZONE', 'UTC'),
|
||||
'enable_utc': app.config.get('CELERY_ENABLE_UTC', True),
|
||||
'task_routes': {'eveai_worker.tasks.create_embeddings': {'queue': 'embeddings',
|
||||
'routing_key': 'embeddings.create_embeddings'}},
|
||||
}
|
||||
celery.conf.update(**celery_config)
|
||||
celery_app.conf.update(**celery_config)
|
||||
|
||||
# Setting up Celery task queues
|
||||
celery.conf.task_queues = (
|
||||
Queue('embeddings', routing_key='embeddings.key', queue_arguments={'x-max-priority': 10}),
|
||||
Queue('llm_interactions', routing_key='llm_interactions.key', queue_arguments={'x-max-priority': 5}),
|
||||
celery_app.conf.task_queues = (
|
||||
Queue('default', routing_key='task.#'),
|
||||
Queue('embeddings', routing_key='embeddings.#', queue_arguments={'x-max-priority': 10}),
|
||||
Queue('llm_interactions', routing_key='llm_interactions.#', queue_arguments={'x-max-priority': 5}),
|
||||
)
|
||||
|
||||
# Ensuring tasks execute with Flask application context
|
||||
@@ -28,5 +37,11 @@ def init_celery(celery, app):
|
||||
|
||||
|
||||
def make_celery(app_name, config):
|
||||
celery = Celery(app_name, broker=config['CELERY_BROKER_URL'], backend=config['CELERY_RESULT_BACKEND'])
|
||||
return celery
|
||||
return celery_app
|
||||
|
||||
|
||||
def _get_current_celery():
|
||||
return celery_app
|
||||
|
||||
|
||||
current_celery = LocalProxy(_get_current_celery)
|
||||
Reference in New Issue
Block a user