Avoid packing more than 1024 messages in a single container

This commit is contained in:
Lonami Exo
2018-11-19 08:29:44 +01:00
parent f90dd76f4c
commit 207d5ebdcb
2 changed files with 8 additions and 2 deletions

View File

@@ -53,8 +53,9 @@ class MessagePacker:
batch = []
size = 0
# Fill a new batch to return while the size is small enough
while self._deque:
# Fill a new batch to return while the size is small enough,
# as long as we don't exceed the maximum length of messages.
while self._deque and len(batch) <= MessageContainer.MAXIMUM_LENGTH:
state = self._deque.popleft()
size += len(state.data) + TLMessage.SIZE_OVERHEAD