mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
4d91d1cadc
moved to brains # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --------- Co-authored-by: Antoine Dewez <44063631+Zewed@users.noreply.github.com>
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
# celery_config.py
|
|
import os
|
|
|
|
from celery import Celery
|
|
|
|
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL", "")
|
|
CELERY_BROKER_QUEUE_NAME = os.getenv("CELERY_BROKER_QUEUE_NAME", "quivr")
|
|
|
|
celery = Celery(__name__)
|
|
|
|
if CELERY_BROKER_URL.startswith("sqs"):
|
|
broker_transport_options = {
|
|
CELERY_BROKER_QUEUE_NAME: {
|
|
"my-q": {
|
|
"url": CELERY_BROKER_URL,
|
|
}
|
|
}
|
|
}
|
|
celery = Celery(
|
|
__name__,
|
|
broker=CELERY_BROKER_URL,
|
|
task_serializer="json",
|
|
task_concurrency=4,
|
|
worker_prefetch_multiplier=1,
|
|
broker_transport_options=broker_transport_options,
|
|
)
|
|
celery.conf.task_default_queue = CELERY_BROKER_QUEUE_NAME
|
|
elif CELERY_BROKER_URL.startswith("redis"):
|
|
celery = Celery(
|
|
__name__,
|
|
broker=CELERY_BROKER_URL,
|
|
backend=CELERY_BROKER_URL,
|
|
task_concurrency=4,
|
|
worker_prefetch_multiplier=1,
|
|
task_serializer="json",
|
|
)
|
|
else:
|
|
raise ValueError(f"Unsupported broker URL: {CELERY_BROKER_URL}")
|