pyrofork: Adapt uvloop changes

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
wulan17 2025-12-08 02:47:12 +07:00
parent 491444dbd6
commit 3910c4ef93
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420
2 changed files with 11 additions and 2 deletions

View file

@ -95,7 +95,12 @@ class Dispatcher:
def __init__(self, client: "pyrogram.Client"):
self.client = client
self.loop = asyncio.get_event_loop()
try:
loop = asyncio.get_event_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
self.loop = loop
self.handler_worker_tasks = []
self.locks_list = []

View file

@ -29,7 +29,11 @@ from pyrogram.methods.utilities import idle as idle_module, compose as compose_m
def async_to_sync(obj, name):
function = getattr(obj, name)
main_loop = asyncio.get_event_loop()
try:
main_loop = asyncio.get_event_loop()
except RuntimeError:
main_loop = asyncio.new_event_loop()
asyncio.set_event_loop(main_loop)
def async_to_sync_gen(agen, loop, is_main_thread):
async def anext(agen):