文章内容

2022/8/21 11:10:14,作 者: 黄兵

PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider.

今天使用 BlockingScheduler() 定时器的时候出现了如下⚠:

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':

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(next_fire_time)

出现问题的原因:

应该是 pytz 存在问题,具体原因未作研究。

解决方案:

1、可以直接修改调度程序,设置时区:

scheduler = BlockingScheduler(timezone="Europe/Berlin")

或者这样写也可以:

import tzlocal

scheduler = BlockingScheduler(timezone=str(tzlocal.get_localzone()))

2、也可以将 APScheduler 升级到 3.9.1 可以解决上面的⚠。


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider.

分享到:

发表评论

评论列表