changed to multi threads
Browse files- controller.py +4 -2
controller.py
CHANGED
@@ -34,6 +34,10 @@ matplotlib.use('Agg')
|
|
34 |
# Initialize FastAPI app
|
35 |
app = FastAPI()
|
36 |
|
|
|
|
|
|
|
|
|
37 |
# Ensure the cache directory exists
|
38 |
os.makedirs("/app/cache", exist_ok=True)
|
39 |
|
@@ -579,8 +583,6 @@ def groq_chart(csv_url: str, question: str):
|
|
579 |
current_langchain_chart_key_index = 0
|
580 |
current_langchain_chart_lock = threading.Lock()
|
581 |
|
582 |
-
max_cpus = os.cpu_count()
|
583 |
-
print("Available CPUs:", max_cpus)
|
584 |
|
585 |
# Use a process pool to run CPU-bound chart generation
|
586 |
process_executor = ProcessPoolExecutor(max_workers=10)
|
|
|
34 |
# Initialize FastAPI app
|
35 |
app = FastAPI()
|
36 |
|
37 |
+
# Initialize the ProcessPoolExecutor
|
38 |
+
max_cpus = os.cpu_count()
|
39 |
+
print("Available CPUs:", max_cpus)
|
40 |
+
|
41 |
# Ensure the cache directory exists
|
42 |
os.makedirs("/app/cache", exist_ok=True)
|
43 |
|
|
|
583 |
current_langchain_chart_key_index = 0
|
584 |
current_langchain_chart_lock = threading.Lock()
|
585 |
|
|
|
|
|
586 |
|
587 |
# Use a process pool to run CPU-bound chart generation
|
588 |
process_executor = ProcessPoolExecutor(max_workers=10)
|