mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Fix a couple of inconsistencies in the public interface (#1102)
* Create `_NOT_A_REQUEST` when needed. Currently, modifications in the raised exception would be "global". * `retries` parameters were actually attempts. This has been fixed to actually be the amount of retries, so 0 now means don't retry. * Helper function to deal with retries instead of using a range with different styles every time.
This commit is contained in:

committed by
Lonami

parent
c9e9b82eac
commit
c8f16a4e89
@@ -72,6 +72,21 @@ def strip_text(text, entities):
|
||||
return text
|
||||
|
||||
|
||||
def retry_range(retries):
|
||||
"""
|
||||
Generates an integer sequence starting from 1. If `retries` is
|
||||
negative or ``None`` then sequence is infinite, otherwise it will
|
||||
end at `retries + 1`.
|
||||
"""
|
||||
yield 1
|
||||
if retries is None:
|
||||
retries = -1
|
||||
attempt = 0
|
||||
while attempt != retries:
|
||||
attempt += 1
|
||||
yield 1 + attempt
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
# region Cryptographic related utils
|
||||
|
Reference in New Issue
Block a user