Replace get_event_loop() with get_running_loop() for asyncio compatibility
Hello,
I got `DeprecationWarning: There is no current event loop` when using `dominate v2.9.1` with Python 3.10 or newer.
ref: https://github.com/thombashi/pytablewriter/issues/66
According to the [official Python 3.10 document](https://docs.python.org/3.10/library/asyncio-eventloop.html#asyncio.get_event_loop):
> In Python versions 3.10.0–3.10.8 and 3.11.0 this function (and other functions which use it implicitly) emitted a DeprecationWarning if there was no running event loop, even if the current loop was set on the policy. In Python versions 3.10.9, 3.11.1 and 3.12 they emit a DeprecationWarning if there is no running event loop and no current loop is set. In some future Python release this will become an error.
And it was [deprecated in Python 3.12](https://docs.python.org/3.13/library/asyncio-eventloop.html#asyncio.get_event_loop):
>Deprecated since version 3.12: Deprecation warning is emitted if there is no current event loop. In some future Python release this will become an error.
The document suggests using the `get_running_loop()` function instead of `get_event_loop()` function.
This will resolve: https://github.com/Knio/dominate/issues/198
合并状态:已合并 合并于 2024-12-31 关闭于 2024-12-31 1 条评论