mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Fix handling message payloads that are too large
This commit is contained in:
parent
3d72c10ea5
commit
baa8970bb6
|
@ -69,14 +69,24 @@ class MessagePacker:
|
|||
id(state.request))
|
||||
continue
|
||||
|
||||
# Put the item back since it can't be sent in this batch
|
||||
self._deque.appendleft(state)
|
||||
if batch:
|
||||
# Put the item back since it can't be sent in this batch
|
||||
self._deque.appendleft(state)
|
||||
break
|
||||
|
||||
# If a single message exceeds the maximum size, then the
|
||||
# message payload cannot be sent. Telegram would forcibly
|
||||
# close the connection; message would never be confirmed.
|
||||
#
|
||||
# We don't put the item back because it can never be sent.
|
||||
# If we did, we would loop again and reach this same path.
|
||||
# Setting the exception twice results in `InvalidStateError`
|
||||
# and this method should never return with error, which we
|
||||
# really want to avoid.
|
||||
self._log.warning(
|
||||
'Message payload for %s is too long (%d) and cannot be sent',
|
||||
state.request.__class__.__name__, len(state.data)
|
||||
)
|
||||
state.future.set_exception(
|
||||
ValueError('Request payload is too big'))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user