Flask 赫罗库没有';调度器完成工作后,不要将更改提交到SQLAlchemy数据库
我正在heroku上运行Flask应用程序,并计划实施调度程序。在本地服务器上似乎一切正常,但在Heroku上,它从不向数据库提交更改。我在免费层运行它。代码如下:Flask 赫罗库没有';调度器完成工作后,不要将更改提交到SQLAlchemy数据库,flask,heroku,sqlalchemy,scheduler,Flask,Heroku,Sqlalchemy,Scheduler,我正在heroku上运行Flask应用程序,并计划实施调度程序。在本地服务器上似乎一切正常,但在Heroku上,它从不向数据库提交更改。我在免费层运行它。代码如下: from app import app, db, SteamProfiles, hours_calculator from apscheduler.schedulers.blocking import BlockingScheduler def daily_users_update(): for profile in S
from app import app, db, SteamProfiles, hours_calculator
from apscheduler.schedulers.blocking import BlockingScheduler
def daily_users_update():
for profile in SteamProfiles.query:
clear_id = profile.steam_profile_id.replace("http://steamcommunity.com/profiles/", "")
status, hours = hours_calculator(clear_id)
profile.hours_in_2_weeks = hours
print(profile.hours_in_2_weeks)
db.session.commit()
scheduler = BlockingScheduler()
scheduler.add_job(daily_users_update, "interval", seconds=30)
scheduler.start()
如果我通过heroku终端运行它,我会看到它会在几个小时内更新,但不会更新数据库。此外,在运行时没有错误,只有来自执行的日志
以下是程序文件:
web: gunicorn app:app
clock: python updater.py
我不明白它有什么问题,所以任何建议都将不胜感激。谢谢大家! 当在本地系统上部署API时,它能工作吗?是的,我在本地导出它,在heroku上导出它,它在env变量中