我正在使用APScheduler库来运行我的一个功能。但是,在执行实际函数之前,我总是会遇到两个错误,但它总是在第三次尝试时正确执行。为什么总是错过它的目标运行两次?
错误:
Press Ctrl+Break to exit Pending jobs: process_new_tracking_data (trigger: interval[0:05:00], pending) Run time of job "process_new_tracking_data (trigger: interval[0:05:00], next run at: 2017-08-09 13:54:57 EDT)" was missed by 0:00:03.760132 Run time of job "process_new_tracking_data (trigger: interval[0:05:00], next run at: 2017-08-09 13:59:57 EDT)" was missed by 0:00:02.039508 completed! # print statement at the end of process_new_tracking_data`
event_handler文件:
def main_func():
scheduler = BlockingScheduler()
scheduler.add_executor('processpool')
scheduler.add_job(case2_newconfig.process_new_tracking_data, 'interval', minutes=5, max_instances=1)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
scheduler.print_jobs()
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass`
主文件:
if __name__ == '__main__':
freeze_support()
process = Popen(event_handler.main_func())`