-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add run_async parameter to ConversationHandler #2292
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
Add run_async parameter to ConversationHandler #2292
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.
Thanks for your PR!
Looking at the changes, I was wondering if maybe it's a better idea to not override the setting of the handlers but only change it during handle_update
, i.e. something along the lines
setting = handler.rus_async
handler.run_async = True if self.run_async else handler.run_async
handler.handle_updater(update)
handler.run_async = setting
but I'm not 100% sure if that could still have side effects if the same handler object is used in two places … Currently Dispatcher.process_update
is calling handle_update()
one after the other, even if internally they might call Dispatcher.run_async
but if that's changed at some point and the above approach will be hard to debug. and maybe the use case for having the same handler object in multiple places is small enough to just go with overriding.
@Poolitzer do you have an opinion on this?
PS: JobQueue fails are obviously unrelated. Please apply this fix in your PR.
How about deep copying the handlers and with |
Mh, that's risky. What do we do if someone uses a custom handler with a |
Right, didn't know we can define a custom handler but that makes sense. Going back to what we have implemented in this PR. If a user sets |
Yes, my point is that that's rather unexpected. With proper documentation I think I'm okay with it but that's why I asked for pools opinion. BTW, before I forget: we started adding |
I do not. what would be the upside to your suggested solution? |
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.
docs nit-picking
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
I pushed a little bit more doc nitpicking … Thank you for your contribution @zeshuaro ! Merging. |
* Add New Shortcuts to Chat (#2291) * Add shortcuts * Add a note * Add run_async Parameter to ConversationHandler (#2292) * Add run_async parameter * Update docstring * Update test to explicitly specify parameter * Fix test job queue * Add version added tag to docs * Update docstring Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com> * Doc nitpicking Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com> Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de> * Fix rendering in messageentity Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> Co-authored-by: zeshuaro <joshuaystang@gmail.com> Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
run_async
parameter toConversationHandler
run_async
is set toTrue
, overrides all handlers in thisConversationHandler
withrun_async
equals toTrue