Spaces:
Sleeping
Sleeping
File size: 1,375 Bytes
30b1610 4f32597 a27816a dd10f90 30b1610 dd10f90 8190051 dd10f90 de3b744 dd10f90 de3b744 dd10f90 de3b744 dd10f90 de3b744 dd10f90 de3b744 dd10f90 55c9531 dd10f90 1bac4cd dd10f90 edf1ecb dd10f90 a3558a8 dd10f90 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import os
import sys
from pathlib import Path
import gradio as gr
# 添加当前目录和src目录到模块搜索路径
current_dir = os.path.dirname(os.path.abspath(__file__))
src_dir = os.path.join(current_dir, "src")
if current_dir not in sys.path:
sys.path.append(current_dir)
if src_dir not in sys.path:
sys.path.append(src_dir)
from src.queue_manager import QueueManager
from src.evaluator import evaluate
from src.ui import EvaluationUI
def main():
"""主函数,创建并启动应用"""
# 创建队列管理器
queue_manager = QueueManager()
# 设置评估函数
queue_manager.set_evaluator(evaluate)
# 创建UI
ui = EvaluationUI(queue_manager)
app = ui.create_evaluation_interface()
# 启动清理线程
import threading
import time
def cleanup_thread():
"""定期清理已完成的请求"""
while True:
try:
queue_manager.clean_completed(max_age=3600) # 清理1小时前的已完成请求
except Exception as e:
print(f"Error in cleanup thread: {e}")
time.sleep(600) # 每10分钟运行一次
cleanup_thread = threading.Thread(target=cleanup_thread, daemon=True)
cleanup_thread.start()
# 返回应用
return app
if __name__ == "__main__":
app = main()
app.launch() |