INNER CODE UNIT · Python
startup
kfcx/Streaming-Media-Server-Pro · app/api/__init__.py:53
async def startup():
import pytz
executors = {
'default': ThreadPoolExecutor(5),
'processpool': ProcessPoolExecutor(2)
}
job_defaults = {
'coalesce': True, # 默认为新任务关闭合并模式()
'max_instances': 3 # 设置新任务的默认最大实例数为3
}
global scheduler
scheduler = BackgroundScheduler()
scheduler.configure(executors=executors, job_defaults=job_defaults,
timezone=pytz.timezone('Asia/Shanghai'))
# cron表达式
# 0 0 * * 0-6 每天凌晨执行一次 更新epg
# 0 * * * * 每1小时执行一次 清理缓存
# */10 * * * * 每10分钟执行一次 清理缓存的视频文件