catalog-agent/task_queue/config.py
2025-10-18 09:20:59 +08:00

27 lines
836 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Queue configuration using SqliteHuey for asynchronous file processing.
"""
import os
from huey import SqliteHuey
from datetime import timedelta
# 确保queue_data目录存在
queue_data_dir = os.path.join(os.path.dirname(__file__), '..', 'queue_data')
os.makedirs(queue_data_dir, exist_ok=True)
# 初始化SqliteHuey
huey = SqliteHuey(
filename=os.path.join(queue_data_dir, 'huey.db'),
name='file_processor', # 队列名称
always_eager=False, # 设置为False以启用异步处理
utc=True, # 使用UTC时间
)
# 设置默认任务配置
huey.store_errors = True # 存储错误信息
huey.max_retries = 3 # 最大重试次数
huey.retry_delay = timedelta(seconds=60) # 重试延迟
print(f"SqliteHuey队列已初始化数据库路径: {os.path.join(queue_data_dir, 'huey.db')}")