| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Also changes the default value for `bootstrap_retries` on polling
There was a problem hiding this comment.
Im just asking questions at this point
Sorry, something went wrong.
| self.__polling_task = asyncio.create_task( | ||
| self._network_loop_retry( | ||
| network_retry_loop( | ||
| is_running=lambda: self.running, |
There was a problem hiding this comment.
why is that a lambda?
Sorry, something went wrong.
There was a problem hiding this comment.
this line expects a callable. If we simply pass is_runnig=self.running and edit above line to
while is_running:then we have an infinite loop, b/c setting self.running=False within Updater won't change the value in the network retry loop :) There are probably a billion other ways do to this (pass an object with a running attribute to check, pass a dict with a corresponding entry, pass an event …). This one seemed rather straight forward to me, but I'm open to changing it. Accepting an instance of
class HasRunning(Protocol):
running: boolwould sound like the next best thing to me at first glance
Sorry, something went wrong.
|
@Eldinnie
I hope that helps... |
Sorry, something went wrong.
|
and why did i tag Eldinnie instead of @Bibo-Joshi ? it's my memory playing tricks on me. lol. |
Sorry, something went wrong.
|
Thanks very much for your insights @tsnoam ! The bootstrapping phase is indeed still needed. It deletes the previous webhook if you run polling, sets a new webhook if your run in webhook mode and drops pending updates if requested. Do you recall why you chose indefinite retries over doing a limited number of retries (say, 3)?. Even though we have logging, indefinite retries can get you in a situation where the process is running in a healthy way (eagerly retrying to set the webhook) but the bot doesn't react at all. That sounds undesirable to me. A limitd number of retries OTOH would be a sane effort of getting things going whil still preventing that the process get's stuck in an unusable state without explicit indication to the user. Moreover I noticed that for webhook mode, the retries were kept at "none". I suspect that this was an oversight: The docstring was updated, but not the signature: https://github.com/python-telegram-bot/python-telegram-bot/pull/1018/files#r1948035215 |
Sorry, something went wrong.
we chose the option of indefinite retries (and afair, with appropriate logging). that way we make sure that the bot is properly started and will be started eventually. aborting seemed like too much, after all, the user will just need to restart the bot and come to the same "problematic" part of the initialization. so what's the point in that?
I'm not sure about it. The initialization phase is the for a reason. Skipping it might lead to a limbo state in which you don't know exactly what happens.
Could be an oversight. That much I don't remember. |
Sorry, something went wrong.
I would not skip it, but rather abort if the bootstrapping phase fails. Meaning that fater n < ∞ retries you either have a bot that's able to handle updates or the process has shut down. But okay, I get your reasoning and now have to decide what to make of it 😅 Thanks for the input! |
Sorry, something went wrong.
|
as long as you can get to an expected state, any solution is good. |
Sorry, something went wrong.
|
I think a finite number of retries is more than enough as long as the delay between them is large enough to eliminate intermittent connectivity problems as the source of potential problems. Eg. in my issue report the problem was that the service was brought up before network/DNS was online. This state is usually resolved within the first 10-20 seconds after boot. Having an infinite amount of retries by default sound dangerous and may instead hide problems which the user wants the be notified about (by the service exiting) |
Sorry, something went wrong.
So far I have implemented the initial retry-interval to 0 seconds for Application.initialize python-telegram-bot/telegram/ext/_application.py Line 1056 in 315a97f but I see that the bootstrapping within Updater uses an initial interval of 1 second - I can use that for Application as well: python-telegram-bot/telegram/ext/_updater.py Line 715 in 315a97f Note that the retry-loop retries immediately on timeout errors. On other errors, the interval is increased step by step up to 30 seconds: python-telegram-bot/telegram/ext/_utils/networkloop.py Lines 114 to 145 in 315a97f Specifying the retry-interval is currently not exposed to the user in the Updater.start_* methods and for starters that would seem like a bit of overkill, TBH. @septatrix would this + (customizable) finite number of retries be enough for you? |
Sorry, something went wrong.
I think having a default 1s interval is better than 0s - or at least something non-zero. Depending on how far along the network stack is the connections would try instantly instead of after a timeout so adding a small delay (such as the 1s) on our side is better.
On timeout errors this should not be a problem because the timeout itself will result in some delay (though it also wouldn't hurt to wait, it's just not necessary).
I agree. As long as the default interval is non-zero it should be fine for most people.
Yes, as far as I understand how this is hooked up now this would be enough for me. Small aside while peeking at the code I found a small curiosity, nothing urgent: I noticed the slack added to RetryAfter exceptions (introduced in a68cf8d) is different from the one in AIORateLimiter. If you already extract it into a variable maybe put it in some shared location? However, this is completely independent from the rest of this PR so feel free to disregard it |
Sorry, something went wrong.
❌ 2 Tests Failed:
To view more test analytics, go to the Test Analytics Dashboard |
Sorry, something went wrong.
|
updated the tests, ready for review :) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
When ready, closes #4657.
This also changes the default value for bootstrap_retries for start/run_polling to 0. Previously the logic was roughly
I now changed this to
I think this is saner, and I'm not even sure if indefinite retries during the bootstrapping phase were ever actually intended …
ToDo