🐛 fix(celery_app.py): add return type annotation to make_celery function to improve code readability and maintainability

🔧 chore(celeryconfig.py): update broker_url default value to use RabbitMQ instead of Redis for better performance and scalability
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-23 23:28:37 -03:00
commit befe79775b
2 changed files with 3 additions and 2 deletions

View file

@ -1,7 +1,7 @@
from celery import Celery # type: ignore
def make_celery(app_name: str, config: str):
def make_celery(app_name: str, config: str) -> Celery:
celery_app = Celery(app_name)
celery_app.config_from_object(config)
celery_app.conf.task_routes = {"langflow.worker.tasks.*": {"queue": "langflow"}}

View file

@ -4,7 +4,8 @@ import os
langflow_redis_host = os.environ.get("LANGFLOW_REDIS_HOST")
langflow_redis_port = os.environ.get("LANGFLOW_REDIS_PORT")
if "BROKER_URL" in os.environ and "RESULT_BACKEND" in os.environ:
broker_url = os.environ.get("BROKER_URL", "redis://localhost:6379/0")
# RabbitMQ
broker_url = os.environ.get("BROKER_URL", "amqp://localhost")
result_backend = os.environ.get("RESULT_BACKEND", "redis://localhost:6379/0")
elif langflow_redis_host and langflow_redis_port:
broker_url = f"redis://{langflow_redis_host}:{langflow_redis_port}/0"