Skip to content
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

Improve timeouts handling in conversation handlers #2417

Merged
merged 19 commits into from
Apr 30, 2021
Merged

Conversation

starry-shivam
Copy link
Member

Closes #2407

Signed-off-by: starry69 <starry369126@outlook.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the comment I left, I'm still missing a few things:

  • We should add a note that timeout with run_async may fail, if the promise takes longer than the timeout (as described in Improve timeouts handling in conversation handlers #2417)

  • We need a test that makes sure the timeout handlers are not triggered, if the promise resolves to CH.END. Ideally, we'd also have a test that makes sure that stuff still works if the promise raises an exception

  • Timeout of child conversations needs to be detected by parent conversations somehow. If we can't get that to work, the added warning needs to be reformulated and the limitation needs to be documented. picking up my idea from off-line to have check_update check if the child has timed out in the meantime: that's not stright forward, as the childs state is then None and also the child may be used in multiple parent conversations (having the same CH instance as child in multiple parents is surely somewhat crazy but we can't prevent that either …).

    TBH while typing this I feel like it may just not be worth the effort and we might just want to document the limitation for now and revisit only if someone complains …

PS: most of the test fails are due to #2409

telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
Signed-off-by: starry69 <starry369126@outlook.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My third bullet point remains to be resolved. Do you have a preference on that?
Test failures: Seems like TG doesn't like our test bots anymore … I had problems with the fallback bots on local tests in the last time.

tests/test_conversationhandler.py Outdated Show resolved Hide resolved
tests/test_conversationhandler.py Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
@starry-shivam
Copy link
Member Author

My third bullet point remains to be resolved. Do you have a preference on that?

Imo we should leave it for now as you said, and just add a note in documentation that: using timeouts with nested conversation may cause troubles. TBH I've never seen anyone complaining about timeouts in nested conversation triggering incorrectly, even when it was bugged, which tells that users rarely use timeouts in nested conversation, besides, now we also have a warning in place so ig we should be fine...

@Bibo-Joshi
Copy link
Member

All right. I'd just to reformulate the note & warning in this case, to be more explicit. E.g. something like

Using conversation_timeout with nested conversations is currently not supported. You can still try to use it, but it will likely behave differntly from what you expect.

for both

Signed-off-by: starry69 <starry369126@outlook.com>
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll wait with merging, though, let's first see if we can get the tests to work again …

@starry-shivam
Copy link
Member Author

Thanks! I'll wait with merging, though, let's first see if we can get the tests to work again …

Yep sure 👍

Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code changes look good to me

telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Show resolved Hide resolved
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ!

@Bibo-Joshi
Copy link
Member

tests now look good, but coverage is not happy. @starry69 can you check why line 647 in CH is not covered?

Signed-off-by: starry69 <starry369126@outlook.com>
@starry-shivam
Copy link
Member Author

tests now look good, but coverage is not happy. @starry69 can you check why line 647 in CH is not covered?

Fixed

@Bibo-Joshi Bibo-Joshi added this to the v13.5 milestone Mar 11, 2021
Signed-off-by: starry69 <starry369126@outlook.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Looks like you edited README.rst or README_RAW.rst. I'm just a friendly reminder to apply relevant changes to both of those files :)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Looks like you edited the (dev) requirements or the pre-commit hooks. I'm just a friendly reminder to keep the pre-commit hook versions in sync with the dev requirements and the additional dependencies for the hooks in sync with the requirements :)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there. Relax, I am just a little warning for the maintainers to release directly after merging your PR, otherwise we have broken examples and people might get confused :)

@Bibo-Joshi Bibo-Joshi changed the base branch from master to doc-fixes March 21, 2021 09:14
@Bibo-Joshi Bibo-Joshi changed the base branch from doc-fixes to master March 21, 2021 09:14
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for re-working :)
Overall looks good, I left some remarks

telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Show resolved Hide resolved
telegram/ext/utils/promise.py Show resolved Hide resolved
telegram/ext/utils/promise.py Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
tests/test_conversationhandler.py Show resolved Hide resolved
tests/test_promise.py Outdated Show resolved Hide resolved
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a look at the updates and left some minor comments. Codecov complains that the added except in Promise isn't hit …

telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
Bibo-Joshi and others added 4 commits March 24, 2021 08:11
Signed-off-by: starry69 <starry369126@outlook.com>
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link

@SwayamSodha SwayamSodha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilent Code it's wonderful.

Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience @starry69 ! Almost done, just some minor nit picking left :)

telegram/ext/conversationhandler.py Outdated Show resolved Hide resolved
telegram/ext/conversationhandler.py Show resolved Hide resolved
telegram/ext/utils/promise.py Outdated Show resolved Hide resolved
Signed-off-by: starry69 <starry369126@outlook.com>
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy now :) @Poolitzer do you want to review again?

Copy link
Member

@Poolitzer Poolitzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good QoL change!


Note:
Using `conversation_timeout` with nested conversations is currently not
supported. You can still try to use it, but it will likely behave differently
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
supported. You can still try to use it, but it will likely behave differently
supported. You can try to use it, but it will likely behave differently

if isinstance(handler, self.__class__):
warnings.warn(
"Using `conversation_timeout` with nested conversations is currently not "
"supported. You can still try to use it, but it will likely behave "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"supported. You can still try to use it, but it will likely behave "
"supported. You can try to use it, but it will likely behave "

@Bibo-Joshi Bibo-Joshi merged commit 7e55458 into master Apr 30, 2021
@Bibo-Joshi Bibo-Joshi deleted the conv-timeout branch April 30, 2021 08:10
@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check promise states in conversation timeout callback | timeouts & nested conversations
4 participants