Closed Shimada666 closed 2 years ago
你定时任务运行时bot没连上,自然报错。运行时,请注意对bot是否存在的判断
还有scheduler不是BackgroundScheduler是async的那个scheduler(
你定时任务运行时bot没连上,自然报错。运行时,请注意对bot是否存在的判断
还有请问一下,我已经按要求添加了 .env.prod 的 apscheduler 配置,但是还是有 pytz warning,如下
11-19 13:51:33 [SUCCESS] nonebot | NoneBot is initializing...
11-19 13:51:33 [INFO] nonebot | Current Env: prod
11-19 13:51:33 [SUCCESS] nonebot | Succeeded to import "rp"
11-19 13:51:33 [SUCCESS] nonebot | Succeeded to import "monitor"
11-19 13:51:33 [SUCCESS] nonebot | Succeeded to import "nonebot_plugin_apscheduler"
/Users/zhengmingzhang/PycharmProjects/ErGoThin/bot/venv/lib/python3.8/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':
11-19 13:51:33 [SUCCESS] nonebot | Succeeded to import "card"
11-19 13:51:33 [SUCCESS] nonebot | Succeeded to import "notice"
11-19 13:51:33 [SUCCESS] nonebot | Running NoneBot...
11-19 13:51:33 [INFO] uvicorn | Started server process [96207]
11-19 13:51:33 [INFO] uvicorn | Waiting for application startup.
/Users/zhengmingzhang/PycharmProjects/ErGoThin/bot/venv/lib/python3.8/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))
11-19 13:51:34 [INFO] nonebot_plugin_apscheduler | Scheduler Started
11-19 13:51:34 [INFO] uvicorn | Application startup complete.
11-19 13:51:34 [INFO] uvicorn | Uvicorn running on http://0.0.0.0:9080 (Press CTRL+C to quit)
/Users/zhengmingzhang/PycharmProjects/ErGoThin/bot/venv/lib/python3.8/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
我尝试在 bot.py 直接 init 初始化时直接进行配置,仍报错,请问有解决办法吗
我的 .env.prod
HOST=0.0.0.0
PORT=9080
APSCHEDULER_AUTOSTART=true
APSCHEDULER_CONFIG={"apscheduler.timezone": "Asia/Shanghai"}
这个忽略就好,上游未更新,不影响使用
描述问题:
按文档创建定时任务(路径:bot/src/plugins/notice/__init__.py)
在主文件中加载(路径:bot/bot.py)
报以下错误
如何复现?
创建上述两个文件即可复现
bot/src/plugins/notice/init.py bot/bot.py
期望的结果
定时任务正常运行
环境信息:
协议端信息:
截图或日志
If applicable, add screenshots to help explain your problem.