mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-06 13:10:22 +03:00
Memory leaks fix
This commit is contained in:
parent
91e5ef852a
commit
6cfb829e58
|
@ -96,17 +96,19 @@ class TcpClient:
|
||||||
self._closed.set()
|
self._closed.set()
|
||||||
|
|
||||||
async def _wait_close(self, coro):
|
async def _wait_close(self, coro):
|
||||||
done, _ = await asyncio.wait(
|
done, running = await asyncio.wait(
|
||||||
[coro, self._closed.wait()],
|
[coro, self._closed.wait()],
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
return_when=asyncio.FIRST_COMPLETED,
|
return_when=asyncio.FIRST_COMPLETED,
|
||||||
loop=self._loop
|
loop=self._loop
|
||||||
)
|
)
|
||||||
|
for r in running:
|
||||||
|
r.cancel()
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
raise self.SocketClosed()
|
raise self.SocketClosed()
|
||||||
if not done:
|
if not done:
|
||||||
raise TimeoutError()
|
raise TimeoutError()
|
||||||
return await done.pop()
|
return done.pop().result()
|
||||||
|
|
||||||
async def write(self, data):
|
async def write(self, data):
|
||||||
"""Writes (sends) the specified bytes to the connected peer"""
|
"""Writes (sends) the specified bytes to the connected peer"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user