mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Remove irrelevant TODOs and add more logging
This commit is contained in:
parent
a5d4e97922
commit
7e7bbcf4c0
|
@ -127,7 +127,6 @@ class Connection(abc.ABC):
|
|||
else:
|
||||
raise result from None
|
||||
|
||||
# TODO Get/put to the queue with cancellation
|
||||
async def _send_loop(self):
|
||||
"""
|
||||
This loop is constantly popping items off the queue to send them.
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import io
|
||||
import logging
|
||||
import struct
|
||||
|
||||
from .mtprotostate import MTProtoState
|
||||
from ..tl import TLRequest
|
||||
from ..tl.core.messagecontainer import MessageContainer
|
||||
|
||||
__log__ = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MTProtoLayer:
|
||||
"""
|
||||
|
@ -64,7 +67,6 @@ class MTProtoLayer:
|
|||
nested inside another message and message container) and
|
||||
returns the serialized message data.
|
||||
"""
|
||||
# TODO write_data_as_message raises on invalid messages, handle it
|
||||
# TODO This method could be an iterator yielding messages while small
|
||||
# respecting the ``MessageContainer.MAXIMUM_SIZE`` limit.
|
||||
#
|
||||
|
@ -84,6 +86,10 @@ class MTProtoLayer:
|
|||
n += 1
|
||||
state.msg_id = self._state.write_data_as_message(
|
||||
buffer, state.data, isinstance(state.request, TLRequest))
|
||||
|
||||
__log__.debug('Assigned msg_id = %d to %s (%x)',
|
||||
state.msg_id, state.request.__class__.__name__,
|
||||
id(state.request))
|
||||
else:
|
||||
last_id = None
|
||||
for s in state:
|
||||
|
@ -92,6 +98,9 @@ class MTProtoLayer:
|
|||
buffer, s.data, isinstance(s.request, TLRequest),
|
||||
after_id=last_id)
|
||||
|
||||
__log__.debug('Assigned msg_id = %d to %s (%x)',
|
||||
s.msg_id, s.request.__class__.__name__,
|
||||
id(s.request))
|
||||
if n > 1:
|
||||
# Inlined code to pack several messages into a container
|
||||
#
|
||||
|
@ -112,7 +121,9 @@ class MTProtoLayer:
|
|||
for s in state:
|
||||
s.container_id = container_id
|
||||
|
||||
return buffer.getvalue()
|
||||
r = buffer.getvalue()
|
||||
__log__.debug('Packed %d message(s) in %d bytes for sending', n, len(r))
|
||||
return r
|
||||
|
||||
def __str__(self):
|
||||
return str(self._connection)
|
||||
|
|
|
@ -343,7 +343,6 @@ class MTProtoSender:
|
|||
if state_list is None:
|
||||
break
|
||||
|
||||
# TODO Debug logs to notify which messages are being sent
|
||||
# TODO Try sending them while no future was cancelled?
|
||||
# TODO Handle cancelled?, arbitrary errors
|
||||
await self._connection.send(state_list)
|
||||
|
@ -362,7 +361,6 @@ class MTProtoSender:
|
|||
Besides `connect`, only this method ever receives data.
|
||||
"""
|
||||
while self._user_connected and not self._reconnecting:
|
||||
# TODO handle incomplete read?
|
||||
__log__.debug('Receiving items from the network...')
|
||||
try:
|
||||
message = await self._connection.recv()
|
||||
|
|
Loading…
Reference in New Issue
Block a user