-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Ensure Safe Handler Looping in Application.process_update/error
#4802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
At first I thought the exception being raised is reasonable, because i'm not sure of a use case where one would need to add handlers dynamically.
And the fact that it was not working, means that PTB users are also just discovering these use cases.
Maybe bot builders (?) where users of the bot add custom command/messages handers base on their input, also then how can the callback part be dynamic.
But that's for users to answer. We can have it.
Just one thought considering how this should work, for now if one dynamically adds a handler in a different group than the one currently selected, it will not be considered for the same update currently being processed, as the list of handlers was copied long before.
would that be a normal/abnormal behavior?
At least I'd say since we're offering add/remove_handler at runtime, it should not throw an exception, independently on how exactly that's achieved :D
Yes, I'd say that's expected. I think there are a few different options one could choosev
Also I've realized that we need the same logic in where we loop over the handler list within the group .. |
* cover also process-error * cover non-critical list-loops * document behavior as implementation detail
Application.process_update
Application.process_update/error
Explanation of additional changes:
|
👍
the hint+warning are sensible imo |
mh, apparently some test case is in a deadlock now 😵💫 will have to investigate. not today, though |
hanging tests apparently were already fixed by 2373596 🕺 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Abdelrahman Elkheir <90580077+aelkheir@users.noreply.github.com>
Based on user input https://t.me/pythontelegrambotgroup/779167
Closes #4803