Closed BA7JCM closed 1 year ago
这是因为 Python 3.12.0 开始弃用了 get_event_loop()
创建 EventLoop 的形式。
根据 https://github.com/cython/cython/issues/5183 报导:
asyncio.get_event_loop() and many other asyncio functions like ensure_future(), shield() or gather(), and also the get_event_loop() method of BaseDefaultEventLoopPolicy now raise a RuntimeError if called when there is no running event loop and the current event loop was not set. Previously they implicitly created and set a new current event loop. DeprecationWarning is no longer emitted if there is no running event loop but the current event loop is set in the policy. (Contributed by Serhiy Storchaka in https://github.com/python/cpython/issues/93453.)
当时 3.12.0a3 的 API 修改为:一旦在未存在 current_event_loop
的状态下使用 get_event_loop()
将会抛出 RuntimeError
错误加上 DeprecationWarning
警告。
后 Python 意识到兼容性问题,从而根据现 https://docs.python.org/3.12/whatsnew/3.12.html#changes-in-the-python-api 说明:
The get_event_loop() method of the default event loop policy now emits a DeprecationWarning if there is no current event loop set and it decides to create one. (Contributed by Serhiy Storchaka and Guido van Rossum in https://github.com/python/cpython/issues/100160.)
现已将抛出 RuntimeError
错误的策略移除。
而又因为 Pyrogram 的 master
分支上 pyrogram/sync.py#L31 仍在使用过时的方法创建 EventLoop
造成在 3.12.0a3 上运行抛出异常。
请确保您已阅读以上注意事项,并勾选下方的确认框。
PagerMaid 版本 (或 Commit Id)
0a4dda08ab19663a18e790e322c86c6690cd7b4b
运行环境
Ubuntu
运行架构
AMD64
重现步骤
从python官网下载python12(https://www.python.org/ftp/python/3.12.0/Python-3.12.0a3.tar.xz )的源码,通过以下命令编译安装python
然后手动安装PagerMaid-Pyro并运行
无法运行,得到以下报错:
系统是Debian11,之所以上面选Ubuntu是因为Ubuntu是基于Debian的,是选项中最接近我的运行环境的一个
期望的结果是什么?
程序正常启动,就像这样:
实际的结果是什么?
在python3.11下可正常运行,但在python3.12下就无法运行
简单的复现代码/链接(可选)
日志记录(可选)
补充说明(可选)
No response