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

wait_until: Add ignored_exceptions parameter #441

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drothlis
Copy link
Contributor

@drothlis drothlis commented Jul 13, 2017

Useful if you've started an HTTP server in a background thread and
you're waiting for it to start up by trying to connect to it; or you've
just sent a key-press to the device-under-test and the FrameObject
you're waiting for doesn't handle unknown states very well; etc.

TODO:

@drothlis
Copy link
Contributor Author

N.B. The name is consistent with Selenium's WebDriverWait which also has an ignored_exceptions parameter.

@drothlis drothlis requested a review from wmanley July 13, 2017 08:20
@drothlis drothlis force-pushed the wait-until-ignored-exceptions branch from c113084 to cc674ff Compare July 15, 2017 08:34
@drothlis
Copy link
Contributor Author

Rebased on top of #444.

_stbt/core.py Show resolved Hide resolved
_stbt/core.py Show resolved Hide resolved
Useful if you've started an HTTP server in a background thread and
you're waiting for it to start up by trying to connect to it; or you've
just sent a key-press to the device-under-test and the FrameObject
you're waiting for doesn't handle unknown states very well; etc.
@drothlis drothlis force-pushed the wait-until-ignored-exceptions branch from cc674ff to f6b099d Compare July 19, 2017 11:33
@drothlis
Copy link
Contributor Author

Rebased onto master after merging #444.

predicate_value = predicate(value)
try:
value = callable_()
except ignored_exceptions as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

This works?!? Fancy that, I guess it makes sense.

value = callable_()
predicate_value = predicate(value)
try:
value = callable_()
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be

try:
    value = callable_()
    predicate_value = predicate(value)
except ...

and then you could avoid the else: block and the second try...except?

Unless this has something to do with not setting value = None if predicate fails?

@wmanley
Copy link
Contributor

wmanley commented Jul 19, 2017

i'd like a little bit more discussion of use-cases here. Can you provide an example of where this would have been useful?

@drothlis
Copy link
Contributor Author

We'll need to test that it raises (or returns None?) if the callable continues to raise exceptions after the timeout.

@drothlis drothlis added this to the v35 milestone May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants