nonebot / nb-cli

NoneBot2 脚手架 / CLI for NoneBot2
https://cli.nonebot.dev
MIT License
156 stars 17 forks source link

[bug]在`Windows`平台上退出bot时报错 #61

Closed shoucandanghehe closed 1 year ago

shoucandanghehe commented 1 year ago

Windows平台上使用nb-cli运行bot,并且设置FASTAPI_RELOAD=false时,Ctrl-C退出bot报错:

02-02 10:43:04 [INFO] logging | connection open
02-02 10:43:05 [INFO] logging | Shutting down
02-02 10:43:05 [WARNING] nonebot | OneBot V11 | WebSocket for Bot ********** closed by peer
02-02 10:43:05 [INFO] logging | connection closed
02-02 10:43:05 [INFO] logging | Finished server process [15776]
02-02 10:43:05 [ERROR] logging | Traceback (most recent call last):
  File "venv\path\Lib\site-packages\starlette\routing.py", line 674, in lifespan
    await receive()
  File "venv\path\Lib\site-packages\uvicorn\lifespan\on.py", line 137, in receive
    return await self.receive_queue.get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\asyncio\queues.py", line 158, in get
    await getter
asyncio.exceptions.CancelledError

使用python bot.py运行正常

环境:

yanyongyu commented 1 year ago

上游问题,随机触发,忽略即可

nbcli也是运行的python bot.py没区别

shoucandanghehe commented 1 year ago

上游问题

猜到了( 或许可以创建一个label upstream issues

随机触发,忽略即可

不过触发概率我这边测是10/10(

yanyongyu commented 1 year ago

你可以试试启动nb然后啥也别连,等两三秒,再ctrl c

shoucandanghehe commented 1 year ago

你可以试试启动nb然后啥也别连,等两三秒,再ctrl c

02-02 11:20:58 [INFO] logging | Started server process [31856]
02-02 11:20:58 [INFO] logging | Waiting for application startup.
02-02 11:20:58 [INFO] logging | Application startup complete.
02-02 11:20:58 [INFO] logging | Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
02-02 11:22:46 [INFO] logging | Shutting down
02-02 11:22:46 [INFO] logging | Finished server process [31856]
02-02 11:22:46 [ERROR] logging | Traceback (most recent call last):
  File "venv\path\Lib\site-packages\starlette\routing.py", line 674, in lifespan
    await receive()
  File "venv\path\Lib\site-packages\uvicorn\lifespan\on.py", line 137, in receive
    return await self.receive_queue.get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\asyncio\queues.py", line 158, in get
    await getter
asyncio.exceptions.CancelledError

🤔

yanyongyu commented 1 year ago

这问题uvicorn和starlette都得背一点锅,uvicorn在Windows上的处理到现在没修,starlette把CancelledError给捕获了