mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Avoid exceeding maximum container size
This issue would likely be triggered when automatically merging multiple requests into a single one while having their size exceed 1044456 bytes like SaveFilePartRequest. This commit avoids such issue by keeping track of the current size, and if it exceeds the limit, avoid merge.
This commit is contained in:
@@ -749,14 +749,17 @@ class _ContainerQueue(asyncio.Queue):
|
||||
isinstance(result.obj, MessageContainer):
|
||||
return result
|
||||
|
||||
size = result.size()
|
||||
result = [result]
|
||||
while not self.empty():
|
||||
item = self.get_nowait()
|
||||
if item == _reconnect_sentinel or\
|
||||
isinstance(item.obj, MessageContainer):
|
||||
if (item == _reconnect_sentinel or
|
||||
isinstance(item.obj, MessageContainer)
|
||||
or size + item.size() > MessageContainer.MAXIMUM_SIZE):
|
||||
self.put_nowait(item)
|
||||
break
|
||||
else:
|
||||
size += item.size()
|
||||
result.append(item)
|
||||
|
||||
return result
|
||||
|
Reference in New Issue
Block a user