您的位置:首页技术文章
文章详情页

python bottle跑起来以后,定时执行的任务为什么每次都重复(多)执行一次?

浏览:42日期:2022-09-11 11:03:23

问题描述

方法定时器里面的方法getDataListFromBKY,在服务器跑起来以后每次都执行两次,如果单独放在一个.py文件里面执行就执行一次.这是哪里出错了呢? 希望大神解答一下

sched = BackgroundScheduler()sched.add_job(getDataListFromBKY, ’interval’, seconds=15) # 采集时间间隔sched.start()@app.route(’/’, method=’GET’)def query_data(): for key, value in request.params.items():if key == ’fun’ and value == ’query’: print(key + ’ : ’ + value) dic = query_content() print(dic) return dicapp.run(host=’localhost’,port=8080, debug=True,reloader=True, server=’gunicorn’, workers=4)

问题解答

回答1:

检查getDataListFromBKY 是不是在另一个模块中调用了一次??

标签: Python 编程