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