欢迎大家来到IT世界,在知识的湖畔探索吧!
遇到的警告,并不影响程序的运行!最近升级了才发现的这个警告,以前没有。
C:\ProgramData\Anaconda3\lib\site-packages\apscheduler\util.py:95: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
if obj.zone == 'local':
C:\ProgramData\Anaconda3\lib\site-packages\apscheduler\triggers\cron\__init__.py:146: PytzUsageWarning: The normalize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
return self.timezone.normalize(dateval + difference), fieldnum
C:\ProgramData\Anaconda3\lib\site-packages\apscheduler\triggers\cron\__init__.py:159: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
return self.timezone.localize(datetime(**values))
欢迎大家来到IT世界,在知识的湖畔探索吧!
正确的解决方案,在配置里面加入 SCHEDULER_TIMEZONE = “Asia/Shanghai”
欢迎大家来到IT世界,在知识的湖畔探索吧!class Config(object): # 创建配置,用类
SCHEDULER_API_ENABLED = True
SCHEDULER_TIMEZONE = "Asia/Shanghai" # 注意这里,这里就是解决方案
app = Flask("app")
CORS(app, supports_credentials=True)
app.config.from_object(Config()) # 为实例化的flask引入配置
网络上找到的其他解决方案:(实际测试这个并不好用,不能解决问题!)
from flask_apscheduler import APScheduler
from apscheduler.schedulers.background import BackgroundScheduler
aps = APScheduler(scheduler=BackgroundScheduler(timezone='Asia/Shanghai'))
希望能帮助到需要的小伙伴。
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/32166.html