修复:WebUI环境检查因Asyncio Windows兼容性而失败并且无任何错误提示#901
Open
Jaryan-luck wants to merge 2 commits into
Open
Conversation
修复Asyncio Windows兼容性
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复:环境检查因Asyncio Windows兼容性而失败并且无任何错误提示:)
问题
在Windows下使用WebUI时,环境检查功能卡在“Environment check error”且界面上没有任何具体的错误提示
原因分析
调用
GET /api/env/check时,check_environment抛出不带任何描述信息的异常NotImplementedError(),返回的json中error字段为空,导致前端提示“环境检查失败”看不到任何具体信息。Uvicorn在默认情况下使用WindowsSelectorEventLoopPolicy
这个事件循环对子进程和控制台的支持并不完善,
当使用SelectorEventLoop事件循环时,asyncio.create_subprocess_exec 会抛 NotImplementedError
解决方案
Windows环境下环境检测使用线程池执行同步子进程
返回错误消息的格式改成了:异常类型:详细描述,不会一点提示都没有😀
测试用例
Windows:
修复前:前端检测环境报错Environment check error,可能无详细信息;
修复后:环境检查成功执行,并返回正常输出,或至少给出明确错误提示(NotImplemented:Unknown)。