harshil21 · GitHub

It seems that we increment retries for every loop iteration, even if the callback succeeded and there were no errors from the TG API:

finally:
retries += 1

This conflicts with the logic of checking the number of retries done:

except TelegramError as telegram_exc:
if on_err_cb:
on_err_cb(telegram_exc)
if max_retries < 0 or retries < max_retries:

It also seems that we don't reset retries = 0 when there are no errors returned.

Read the original on github.com ↗