39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""测试调度配置"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from celery_app import app
|
|
from datetime import datetime
|
|
|
|
def check_schedule_config():
|
|
"""检查当前的调度配置"""
|
|
print("当前Celery调度配置:")
|
|
print("=" * 40)
|
|
|
|
beat_schedule = app.conf.beat_schedule
|
|
|
|
for task_name, task_config in beat_schedule.items():
|
|
schedule_seconds = task_config['schedule']
|
|
task_path = task_config['task']
|
|
|
|
# 转换为可读格式
|
|
if schedule_seconds < 60:
|
|
interval = f"{schedule_seconds}秒"
|
|
elif schedule_seconds < 3600:
|
|
minutes = schedule_seconds / 60
|
|
interval = f"{minutes:.1f}分钟"
|
|
else:
|
|
hours = schedule_seconds / 3600
|
|
interval = f"{hours:.1f}小时"
|
|
|
|
print(f"🕐 任务名称: {task_name}")
|
|
print(f"📝 任务路径: {task_path}")
|
|
print(f"⏰ 执行间隔: {interval} ({schedule_seconds}秒)")
|
|
print(f"🔧 队列: {task_config.get('options', {}).get('queue', 'default')}")
|
|
print()
|
|
|
|
if __name__ == "__main__":
|
|
check_schedule_config() |