mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-27 01:34:29 +03:00
Fix connection never receiving and missing clone method
This commit is contained in:
parent
2fd51b8582
commit
daf94e416b
|
@ -35,15 +35,23 @@ class Connection(abc.ABC):
|
||||||
|
|
||||||
self._disconnected.clear()
|
self._disconnected.clear()
|
||||||
self._send_task = self._loop.create_task(self._send_loop())
|
self._send_task = self._loop.create_task(self._send_loop())
|
||||||
self._recv_task = self._loop.create_task(self._send_loop())
|
self._recv_task = self._loop.create_task(self._recv_loop())
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
"""
|
"""
|
||||||
Disconnects from the server.
|
Disconnects from the server.
|
||||||
"""
|
"""
|
||||||
self._disconnected.set()
|
self._disconnected.set()
|
||||||
|
self._send_task.cancel()
|
||||||
|
self._recv_task.cancel()
|
||||||
self._writer.close()
|
self._writer.close()
|
||||||
|
|
||||||
|
def clone(self):
|
||||||
|
"""
|
||||||
|
Creates a clone of the connection.
|
||||||
|
"""
|
||||||
|
return self.__class__(self._ip, self._port, loop=self._loop)
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
"""
|
"""
|
||||||
Sends a packet of data through this connection mode.
|
Sends a packet of data through this connection mode.
|
||||||
|
@ -75,8 +83,13 @@ class Connection(abc.ABC):
|
||||||
This loop is constantly putting items on the queue as they're read.
|
This loop is constantly putting items on the queue as they're read.
|
||||||
"""
|
"""
|
||||||
while not self._disconnected.is_set():
|
while not self._disconnected.is_set():
|
||||||
data = await self._recv()
|
try:
|
||||||
await self._recv_queue.put(data)
|
data = await self._recv()
|
||||||
|
except asyncio.IncompleteReadError:
|
||||||
|
if not self._disconnected.is_set():
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
await self._recv_queue.put(data)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def _send(self, data):
|
def _send(self, data):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user