-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LimitInvalidError while iter_download #3199
Comments
The
Yeah, said totally another, but In my code, I wrote a function like this, and... it fixes my problem. def pad_request_size(request_size: int) -> int:
'''
This function pads `request_size` to divisible
by 4096 bytes. Note that 1MiB must be divisible
by `request_size`, so it will be not the closest number.
If `request_size` < 4096, then it's not padded.
request_size (`int`):
Amount of requested bytes.
'''
# Check amount of blocks
block_count = request_size/4096
if block_count <= 1:
return request_size
# If it's already divisible by 4096
elif int(block_count) == block_count:
request_size = int(block_count*4096)
else:
# Add 1 block.
request_size = int(block_count+1)*4096
# request_size must be divisible by 1MiB
while 1048576 % request_size:
request_size += 1
return request_size I haven't check it, but it seems that if Also, in Telethon docs there is no any information about 1MiB, so it's can be unclear.
I won't close issue for now, as i don't know if this should work like this, or i missing something. |
Closing in favor of #1720, which is older. |
Checklist
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
and triggered the bug in the latest version.Code that causes the issue
Traceback
More
In the first case i want to download file from
71
byte to50000
. As later i read in docs,request_size
must be a multiply of4096
bytes. So i changed my code toWith no changes so far. I still get this error.
But, when i do this:
Works just perfect. So am i doing something wrong, or there is problem in library code?
I asked in Telethon chat and didn't receive answer. Thanks.
The text was updated successfully, but these errors were encountered: