-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
无法Ctrl C结束HTTP服务器 #67
Comments
試一試反复 CtrlC。我是這樣的
…On Sun., Nov. 20, 2022, 20:36 PSoul, ***@***.***> wrote:
如题
环境为Windows11 + python3.10.2
无法Ctrl C,只能关闭终端窗口并重新打开,有点麻烦
—
Reply to this email directly, view it on GitHub
<#67>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADKGVB5QPMJNH27Y7ZCUAXDWJLGYJANCNFSM6AAAAAASGEMGNY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
不行,看来各位都有这个问题?? |
找到了一個簡單的辦法. 可以使用 aioconsole,而後在執行 cqhttp 的同時再讀取用戶輸入就好了: import asyncio
from aiocqhttp import CQHttp
from aioconsole import ainput
async def interrupter():
while await ainput() != 'exit':
pass
exit()
async def main():
bot = CQHttp()
await asyncio.gather(bot.run_task(), interrupter())
asyncio.run(main()) 鍵盤上鍵入 |
这个问题是由于hypercorn框架内部注册了 signal.SIGINT 信号导致的: 为了使web server能在ctrl+c时才退出,当quart开始运行时,默认会为底层忽略传入 shutdown_trigger ,以使hypercorn自动监听 退出信号。 简易的解决办法定义一个阻塞的异步方法: async def shutdown_trigger_placeholder():
while True:
await asyncio.sleep(1) 作为shutdown_trigger 具名参数传入 CQHttp 的run方法: bot.run(
...
shutdown_trigger=shutdown_trigger_placeholder
) |
如题
环境为Windows11 + python3.10.2
无法Ctrl C,只能关闭终端窗口并重新打开,有点麻烦
The text was updated successfully, but these errors were encountered: