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

Add new stbt.timeout API #546

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add new stbt.timeout API #546

wants to merge 8 commits into from

Conversation

wmanley
Copy link
Contributor

@wmanley wmanley commented Dec 11, 2018

You can now decorate a function with a timeout

@timeout(3)
def test_something():
    ...

or use it as a contextmanager:

with timeout(30):
    while True:
        ...

This greatly simplifies looping and retries in test-scripts. It's inspired by Timeouts and cancellation for humans

TODO:

  • We currently only cope with having a single stack. Generators mean we can have more than one "stack" per thread which will confuse the timeouts.
  • Consider how to attach additional information to a timeout. It would be nice to get a MatchTimeout or similar if that's what we've been doing at the time of the timeout.
  • Write tests
  • Make it actually work

This has printed a warning since v28 was released (Jan 2018).  We've had no
complaints and as far as we know it's unused.  Removing to simplify.
This API has been redundant since we introduced `stbt.match` in 0.21 (Dec
2014).  It's not been a part of the documentation on
https://stb-tester.com/manual ever, so I'm removing it.
This is an attempt at making timeouts more robust and easier to
use.  Instead of passing `timeout_secs` to methods you can use
the `timeout()` decorator.  There can be multiple timeouts active
at any one time.
To make the sleeping interruptable by higher-level timeouts.
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

1 participant