Skip to content

BrainAPI is a knowledge graph–powered AI memory layer that transforms unstructured data into structured knowledge, enabling intelligent search, recommendations, and contextual memory for AI agents and applications.

feat(tasks): added celery max workerc concurrency

Christian4128814e76b6
diff --git a/src/config.py b/src/config.py
index 63b819e..7d47c91 100644
--- a/src/config.py
+++ b/src/config.py
@@ -155,6 +155,17 @@ class MongoConfig:
raise ValueError("Mongo configuration is not complete")
+class CeleryConfig:
+ """
+ Configuration class for the Celery configuration.
+ """
+
+ def __init__(self):
+ self.worker_concurrency = os.getenv("CELERY_WORKER_CONCURRENCY")
+ if [self.worker_concurrency].count(None) > 0:
+ raise ValueError("Celery configuration is not complete")
+
+
class Config:
"""
Configuration class for the application.
@@ -168,6 +179,7 @@ class Config:
self.embeddings = EmbeddingsConfig()
self.mongo = MongoConfig()
self.gcp = GCPConfig()
+ self.celery = CeleryConfig()
self.brainpat_token = os.getenv("BRAINPAT_TOKEN")
diff --git a/src/workers/app.py b/src/workers/app.py
index 18321fe..5f1a9a9 100644
--- a/src/workers/app.py
+++ b/src/workers/app.py
@@ -11,6 +11,8 @@ Modified By: the developer formerly known as Christian Nonis at <alch.infoemail@
import os
from celery import Celery
+from src.config import config
+
os.environ.setdefault("GRPC_ENABLE_FORK_SUPPORT", "1")
REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
@@ -37,4 +39,5 @@ ingestion_app.conf.update(
task_acks_late=True,
task_reject_on_worker_lost=True,
worker_pool="threads",
+ worker_concurrency=config.celery.worker_concurrency,
)