问题
windows开发环境Pycharm通过loop.run_until_complete执行asyncio异步多线程时突然出现报错:
"AttributeError: 'ProactorEventLoop' object has no attribute '_compute_internal_coro'"
最开始怀疑时Python版本问题或者环境配置问题,排查了很久都没有解决问题。
解决步骤
在Google发现了是Pycharm升级到2023.3后导致的,只能回退版本或修改配置
- 在Pycharm使用快捷键 CTRL+Shift+A
- 输入 "Registry..."
- 修改
python.debug.asyncio.repl 取消勾选
- 重启
官方社区
To enable asyncio for the debugger, follow the steps:
- Open PyCharm
- Use Shift + Shift (Search Everywhere)
- In the popup type: and press Enter
Registry
- Find "Registry" in the list of results and click on it.
- In the new popup find line and check the respective checkbox
python.debug.asyncio.repl
- Press Close.
- Restart the IDE.
- The asyncio support will be enabled in the debugger.