nonebot / plugin-apscheduler

APScheduler Support for NoneBot2
https://nonebot.dev/docs/best-practice/scheduler
MIT License
85 stars 10 forks source link

Bug: linux系统下nonebot2.0.0rc3以上启动时无法将apscheduler正确初始化 #28

Closed okashi-ya closed 1 year ago

okashi-ya commented 1 year ago

操作系统

Linux

Python 版本

3.8.2

NoneBot 版本

2.0.0rc4及以上

适配器

OneBot V11 2.2.1和2.2.3(尝试更新适配器版本,但问题依旧)

协议端

无需协议端,单独启动即可

描述问题

linux下使用import nonebot_plugin_apscheduler将定时器import后,nonebot2.0.0rc4及最新版本中没有看到关于定时器初始化成功的代码。 2 0 0 r3

PS:在windows下,2.0.0rc4和2.0.0Stable版本是可以正常初始化定时器的。

看起来2.0.0版本并没有输出“nonebot_plugin_apscheduler | Scheduler Started”这句话,也没有进入到nonebot_plugin_apscheduler__init__.py的_start_scheduler()函数里。 3 根据上面的截图和下面的日志,这个判断是有效的,但是get_driver().on_startup()和get_driver().on_shutdown()没有成功运行。

复现步骤

nonebot 2.0.0rc3 使用import nonebot_plugin_apscheduler初始化启动后 查看apscheduler初始化情况 nonebot 2.0.0 同上查看

期望的结果

2.0.0版本可以正确初始化定时器

截图或日志

rc3: 06-28 22:54:02 [SUCCESS] nonebot | NoneBot is initializing... 06-28 22:54:02 [INFO] nonebot | Current Env: prod plugin_config.apscheduler_autoshart = True scheduler.running=False 06-28 22:54:02 [SUCCESS] nonebot | Succeeded to import "nonebot_plugin_apscheduler" 06-28 22:54:02 [INFO] haruka_bot | 检查 Chromium 更新 06-28 22:54:02 [INFO] haruka_bot | 检查 Playwright 依赖 06-28 22:54:03 [INFO] kmrbot_plugins | LiveRoomMonitorManager running_loop start. 06-28 22:54:03 [SUCCESS] kmrbot_plugins | kmrbot_plugins import success. 06-28 22:54:03 [SUCCESS] nonebot | Succeeded to import "haruka_bot" 06-28 22:54:03 [SUCCESS] nonebot | Running NoneBot... 06-28 22:54:03 [INFO] uvicorn | Started server process [2566] 06-28 22:54:03 [INFO] uvicorn | Waiting for application startup. 1 2 06-28 22:54:03 [INFO] nonebot_plugin_apscheduler | Scheduler Started 06-28 22:54:03 [INFO] haruka_bot | dy_sched 06-28 22:54:03 [INFO] uvicorn | Application startup complete. 06-28 22:54:03 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)

2.0.0: 06-28 23:09:00 [SUCCESS] nonebot | NoneBot is initializing... 06-28 23:09:00 [INFO] nonebot | Current Env: prod plugin_config.apscheduler_autoshart = True scheduler.running=False 06-28 23:09:00 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_apscheduler" 06-28 23:09:00 [INFO] haruka_bot | 检查 Chromium 更新 06-28 23:09:00 [INFO] haruka_bot | 检查 Playwright 依赖 06-28 23:09:02 [INFO] kmrbot_plugins | LiveRoomMonitorManager running_loop start. 06-28 23:09:02 [SUCCESS] kmrbot_plugins | kmrbot_plugins import success. 06-28 23:09:02 [SUCCESS] nonebot | Succeeded to load plugin "haruka_bot" 06-28 23:09:02 [SUCCESS] nonebot | Running NoneBot... 06-28 23:09:02 [INFO] uvicorn | Started server process [3002] 06-28 23:09:02 [INFO] uvicorn | Waiting for application startup. 06-28 23:09:02 [INFO] uvicorn | Application startup complete. 06-28 23:09:02 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)

he0119 commented 1 year ago

请问你的 fastapi 版本是否是 0.93.0 及以上?

yanyongyu commented 1 year ago

请升级你的fastapi版本

okashi-ya commented 1 year ago

请问你的 fastapi 版本是否是 0.93.0 及以上?

linux下为0.89.0 升级至0.98.0后问题解决,感谢提供解决方案

okashi-ya commented 1 year ago

请升级你的fastapi版本

请升级你的fastapi版本

升级至0.98.0后问题解决,感谢提供解决方案