Fix attached to a different loop

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
KurimuzonAkuma 2025-03-06 13:57:53 +03:00 committed by wulan17
parent 1a4c578380
commit 3d71eba4e1
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420
6 changed files with 6 additions and 19 deletions

View file

@ -380,10 +380,7 @@ class Client(Methods):
if isinstance(loop, asyncio.AbstractEventLoop):
self.loop = loop
else:
try:
self.loop = asyncio.get_running_loop()
except RuntimeError:
self.loop = asyncio.new_event_loop()
loop = asyncio.get_event_loop()
def __enter__(self):
return self.start()

View file

@ -55,10 +55,7 @@ class Connection:
if isinstance(loop, asyncio.AbstractEventLoop):
self.loop = loop
else:
try:
self.loop = asyncio.get_running_loop()
except RuntimeError:
self.loop = asyncio.new_event_loop()
self.loop = asyncio.get_event_loop()
async def connect(self) -> None:
for _ in range(Connection.MAX_CONNECTION_ATTEMPTS):

View file

@ -58,10 +58,7 @@ class TCP:
if isinstance(loop, asyncio.AbstractEventLoop):
self.loop = loop
else:
try:
self.loop = asyncio.get_running_loop()
except RuntimeError:
self.loop = asyncio.new_event_loop()
self.loop = asyncio.get_event_loop()
async def _connect_via_proxy(
self,

View file

@ -49,6 +49,6 @@ class Initialize:
await self.dispatcher.start()
self.updates_watchdog_task = asyncio.create_task(self.updates_watchdog())
self.updates_watchdog_task = self.loop.create_task(self.updates_watchdog())
self.is_initialized = True

View file

@ -71,8 +71,7 @@ class Run:
app.run(main())
"""
loop = asyncio.get_event_loop()
run = loop.run_until_complete
run = self.loop.run_until_complete
if coroutine is not None:
run(coroutine)

View file

@ -50,10 +50,7 @@ async def ainput(prompt: str = "", *, hide: bool = False, loop: Optional[asyncio
if isinstance(loop, asyncio.AbstractEventLoop):
loop = loop
else:
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
loop = asyncio.get_event_loop()
with ThreadPoolExecutor(1) as executor:
func = functools.partial(getpass if hide else input, prompt)