问题描述
我在 python 中使用后台调度程序来运行一项作业,该作业进行分析然后更新数据库。下面是相同的代码: 所以预期的行为是它将运行一个线程并等待 15 秒然后运行第二个实例。但这是一起运行两个实例,然后休息 59 秒。以下是我使用时间戳运行的作业的输出
scheduler.add_job(func=print_date_time,trigger="interval",seconds=59)
scheduler.start()
print(scheduler.get_jobs())```
```job started at 02:54:11
in the beginning tweetid : blank new tid is : 1090278987920740353
tid not in the database
job finished
job started at 02:54:13
in the beginning tweetid : blank new tid is : 1090278987920740353
tid not in the database
job finished
job started 02:55:10
in the beginning tweetid : blank new tid is : 1090278987920740353
tid not in the database
job finished
job started 02:55:12
in the beginning tweetid : blank new tid is : 1090278987920740353
tid not in the database
job finished *************************************************************************************************************************************
我正在尝试实现python的这个flask应用程序。 这导致在数据库中插入密钥两次,我收到重复输入错误。
解决方法
你可以试试simple-scheduler。
msg_queue