Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Prevent Flask hot reload from hanging due to early thread startup (#7966)

CharlesHsu241fdf266a37
diff --git a/api/ragflow_server.py b/api/ragflow_server.py
index 024492cecb..f036967bcc 100644
--- a/api/ragflow_server.py
+++ b/api/ragflow_server.py
@@ -28,7 +28,6 @@ import signal
import sys
import time
import traceback
-from concurrent.futures import ThreadPoolExecutor
import threading
import uuid
@@ -125,8 +124,16 @@ if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
- thread = ThreadPoolExecutor(max_workers=1)
- thread.submit(update_progress)
+ def delayed_start_update_progress():
+ logging.info("Starting update_progress thread (delayed)")
+ t = threading.Thread(target=update_progress, daemon=True)
+ t.start()
+
+ if RuntimeConfig.DEBUG:
+ if os.environ.get("WERKZEUG_RUN_MAIN") == "true":
+ threading.Timer(1.0, delayed_start_update_progress).start()
+ else:
+ threading.Timer(1.0, delayed_start_update_progress).start()
# start http server
try: