Add MAX_EXECUTIONS environment variable limit#5272
Open
jardondiego wants to merge 6 commits into
Open
Conversation
IvanBM18
reviewed
May 13, 2026
| execution_count += 1 | ||
| max_executions = environment.get_value('MAX_EXECUTIONS') | ||
| if max_executions and execution_count >= int(max_executions): | ||
| logs.info('Reached MAX_EXECUTIONS limit (%s). Exiting.', max_executions) |
Collaborator
There was a problem hiding this comment.
Nit: Can you format using f strings?
Suggested change
| logs.info('Reached MAX_EXECUTIONS limit (%s). Exiting.', max_executions) | |
| logs.info(f'Reached MAX_EXECUTIONS limit {max_executions}. Exiting.') |
We don't really format strings that way in the project.
Besides i think that using the logs.info() method that way would result in the following log:
....
extras :{
max_executions: 5
},
message: "Reached MAX_EXECUTIONS limit (%s). Exiting."
....
Collaborator
Author
There was a problem hiding this comment.
Good catch! Thanks!
added 4 commits
May 13, 2026 15:44
- Fixed the `TypeError: info() takes 1 positional argument but 2 were given` exception when max_executions limit is reached. - Ensured environment re-evaluation in the `test_max_executions` unit test. - Mocked `update_task_enabled` correctly during tests.
- Handles ValueError if MAX_EXECUTIONS cannot be parsed as an integer. - Removes the invalid value from the environment to prevent repeated errors. - Adds test coverage for the invalid input case.
- Removed extra indentation by utilizing Python's short-circuit evaluation inside a single try-except block.
IvanBM18
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a
MAX_EXECUTIONSenvironment variable that limits the number of tasks the bot will execute before exiting cleanly.This is particularly useful when running a local bot with a
COMMAND_OVERRIDE, allowing developers to restrict the bot to a specific number of iterations rather than looping infinitely.Changes:
execution_counttracker to the maintask_loopinrun_bot.py.MAX_EXECUTIONSis set and reached.run_bot_test.py.