python中的BackgroundScheduler正在运行两个实例而不是1

问题描述

我在 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...