Bibo-Joshi · GitHub

@Bibo-Joshi

@Bibo-Joshi

@Bibo-Joshi

@Bibo-Joshi

Pull Request Overview

Fixes infinite loop behavior when bootstrap_retries=-1 is set in Application.run_* and Updater.start_* methods by properly implementing retry termination conditions.

  • Replaces self.running condition with success tracking for webhook operations
  • Adds is_running parameter to application bootstrap initialization
  • Includes comprehensive tests for both polling and webhook scenarios

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/telegram/ext/_updater.py Implements success tracking for webhook delete/set operations to prevent infinite retries
src/telegram/ext/_application.py Adds proper termination condition for application initialization retries
tests/ext/test_updater.py Adds test coverage for infinite bootstrap retries in updater methods
tests/ext/test_application.py Adds test coverage for infinite bootstrap retries in application run methods
changes/unreleased/4973.PtSpAPsm7wh4PWc4p3uajX.toml Documents the bugfix in changelog
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

aelkheir

Haven't looked at tests yet. while current approach solves the issue, i am wondering if there would be an issue when breaking the loop from within, i.e without the reliance on network_retry_loop.is_running to track success.

Changing this:

while effective_is_running():
try:
await do_action()
if not infinite_loop:
_LOGGER.debug("%s Action succeeded. Stopping loop.", log_prefix)
break

to:

    while effective_is_running():
        try:
            await do_action()
            _LOGGER.debug("%s Action succeeded. Stopping loop.", log_prefix)
            break

edit:
oh that might break polling i guess

@Bibo-Joshi

aelkheir

aelkheir

@Bibo-Joshi

@Bibo-Joshi

Read the original on github.com ↗