From f951a25b03025c09a1393f2184c6909112a835e9 Mon Sep 17 00:00:00 2001 From: Ricky8955555 Date: Mon, 12 Jun 2023 23:29:34 +0800 Subject: [PATCH 1/2] fix: avoid using `asyncio.get_event_loop` (#41) The behaviour of creating a new event loop if one doesn't already exist was removed in Python 3.12 alpha and was allegedly deprecated before then. --- utils/gensession.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/gensession.py b/utils/gensession.py index e38363e..1e6859a 100644 --- a/utils/gensession.py +++ b/utils/gensession.py @@ -1,4 +1,5 @@ import asyncio +import contextlib import os from sys import executable, exit @@ -51,5 +52,5 @@ async def main(): if __name__ == "__main__": - loop = asyncio.get_event_loop() - loop.run_until_complete(main()) + with contextlib.closing(asyncio.new_event_loop()) as loop: + loop.run_until_complete(main()) From e9d3d1fab043e162c5ce5d4a5588fcd232bd8891 Mon Sep 17 00:00:00 2001 From: Ricky8955555 Date: Mon, 12 Jun 2023 23:49:40 +0800 Subject: [PATCH 2/2] fix: create event loop for pyrogram --- pagermaid/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pagermaid/__main__.py b/pagermaid/__main__.py index a8ea56b..f560086 100644 --- a/pagermaid/__main__.py +++ b/pagermaid/__main__.py @@ -1,3 +1,5 @@ +import asyncio +import contextlib from sys import path, platform from os import sep from importlib import import_module @@ -55,4 +57,5 @@ async def main(): await bot.stop() -bot.run(main()) +with contextlib.closing(asyncio.new_event_loop()): + bot.run(main())