定时器的设计

a[1] = tools.jingji.action # 功能函数
a[2] = tools.worldboss.action

#数据库中的数据结构
id,hour,min,times
1, 20, 00,2
2, 20, 00,30
3, 20, 00,234
4, 20, 00,2
5, 20, 00,2
6, 20, 00,1

# 伪代码
plan = getPlanList()
todayHadSend = {}


for id, hour, min,times in plan:
    todayHadSend[id] = times


for id, hour, min,times in plan:
    if now().hour == hour and now().min == min:
        func = a[id]
        if func is not None and todayHadSend[id] > 0:
            func()
            todayHadSend[id] = todayHadSend[id] - 1


# 1. 打印出环境变量
# 2. 读工作空间中的文件
#

猜你喜欢

转载自blog.csdn.net/epeaktop/article/details/78842994