定时调外部任务开启api
This commit is contained in:
39
test_schedule.py
Normal file
39
test_schedule.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user