PRWelBot4SECourse/jobs/tasks.py

41 lines
978 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/python
import sys
sys.path.append('..')
import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
# 定时任务处理与调度
# 测试程序
def func():
now = datetime.datetime.now()
ts = now.strftime('%Y-%m-%d %H:%M:%S')
print('do func time :', ts)
# 扫描数据库获取未完成的到期pr执行相关操作
def check_pr():
# 查询数据库获取未完成的到期pr
# 循环遍历调用接口查询pr状态是否新增评论或者状态为关闭
# 对不活跃的pr调用接口发表评论提醒处理
return
# 定时执行任务
# 参数 func 定时函数 time 间隔时间min
def do_timer_job(func, time):
# 创建调度器BlockingScheduler
scheduler = BlockingScheduler()
# 添加任务,时间间隔5S
scheduler.add_job(func, 'interval', seconds=time, id='timer_job1')
scheduler.start()
if __name__ == '__main__':
do_timer_job(func, 1)