Keep consistent structure and remove done TODO

This commit is contained in:
Lonami Exo 2018-06-09 15:42:10 +02:00
parent acd6025731
commit 7e68274f26
2 changed files with 17 additions and 19 deletions

View File

@ -21,8 +21,6 @@ except ImportError:
__log__ = logging.getLogger(__name__)
# TODO Except asyncio.TimeoutError, ConnectionError, OSError...
# ...for connect, write and read (in the upper levels, not here)
class TcpClient:
"""A simple TCP client to ease the work with sockets and proxies."""
def __init__(self, proxy=None, timeout=5):

View File

@ -250,6 +250,23 @@ class MTProtoSender:
self._reconnecting = False
await self._connect()
def _clean_containers(self, msg_ids):
"""
Helper method to clean containers from the pending messages
once a wrapped msg_id of them has been acknowledged.
This is the only way we can resend TLMessage(MessageContainer)
on bad notifications and also mark them as received once any
of their inner TLMessage is acknowledged.
"""
for i in reversed(range(len(self._pending_containers))):
message = self._pending_containers[i]
for msg in message.obj.messages:
if msg.msg_id in msg_ids:
del self._pending_containers[i]
del self._pending_messages[message.msg_id]
break
# Loops
async def _send_loop(self):
@ -521,23 +538,6 @@ class MTProtoSender:
__log__.debug('Handling new session created')
self.state.salt = message.obj.server_salt
def _clean_containers(self, msg_ids):
"""
Helper method to clean containers from the pending messages
once a wrapped msg_id of them has been acknowledged.
This is the only way we can resend TLMessage(MessageContainer)
on bad notifications and also mark them as received once any
of their inner TLMessage is acknowledged.
"""
for i in reversed(range(len(self._pending_containers))):
message = self._pending_containers[i]
for msg in message.obj.messages:
if msg.msg_id in msg_ids:
del self._pending_containers[i]
del self._pending_messages[message.msg_id]
break
async def _handle_ack(self, message):
"""
Handles a server acknowledge about our messages. Normally