mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Fix attached to a different loop
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
1a4c578380
commit
3d71eba4e1
6 changed files with 6 additions and 19 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue