你好,我已經構建了一個 Flask 網站,并使用 uWSGI 進行了部署。除了使用 apscheduler 運行的數據庫更新代碼之外,一切似乎都按預期工作。我有一個對象,它本質上包含一些數據字典,我想使用 apscheduler 每小時更新一次。當我嘗試正常訪問該對象時,一切都按預期進行。但是,當我嘗試將對象與 apschedulerBackgroundScheduler 一起使用時,該對象不包含任何數據,即使它位于同一內存位置!當在燒瓶頁面中執行時,它會產生:hex id of object: 0x7f58a5e88a60hex id of object.prices: 0x7f58a5e88ac0hex id of object.prices._content_dict: 0x7f58ab0a8180_content_dict: {625: (12925714.285714285, 9044000.0), 34: (8.528115645081806, 8.0), 35: (13.499491140271743, 35.0), 36: (109.86576894948205, 113.1), 37: (37.98743083746043, 42.64), 38: (1311.6629430032253, 1225.0), 39: (1347.7675049393822, 1354.0), 40: (808.3051410710929, 787.0)}type: <class 'app.EVE_interfaces.EVE_ESI_interface.ESI_data_obj'>prices length: 8然而,當由 apscheduler 作業調用時,它會給出:hex id of object: 0x7f58a5e88a60hex id of object.prices: 0x7f58a5e88ac0hex id of object.prices._content_dict: 0x7f58ab0a8180_content_dict: {}type: <class 'app.EVE_interfaces.EVE_ESI_interface.ESI_data_obj'>prices length: 0這里對象的內存位置與以前相同!但是當調度程序調用時_content_dict 包含一個空字典?(數據不會被刪除,因為當我之后再次正常調用它時它仍然存在。)當我使用 Flask 的內置開發服務器時,apscheduler 更新功能工作正常,但不適用于 uWSGI。apscheduler 配置如下:# run update once at the startupdate()# set up scheduler to repeatedly update ESI datascheduler = BackgroundScheduler()scheduler.add_job(func=update, trigger='interval', minutes=_ESI_update_interval)scheduler.start()# Shut down the scheduler when exiting the appatexit.register(lambda: scheduler.shutdown())我的uWSGI.ini如下:[uwsgi]module = main:flask_appmaster = trueprocesses = 1 enable-threads = truesingle-interpreter = truesocket = web_app.sockchmod-socket = 660vacuum = truedie-on-term = truelogto = /home/mainuser/web_app/uwsgi_logs/%n.log有人可以解釋為什么當使用 apscheduler 調用數據時,數據不存在嗎?即使對象內存位置相同?或者我應該如何運行每小時數據庫更新功能?
添加回答
舉報
0/150
提交
取消