Have you ever wanted to make things timeout
stuff after so much time has
elapsed?
Do you have an SLA that dictates that if a certain function isn't performing up to snuff it doesn't reach a certain time limit
pip install timeout.stuff
- Fork the repo and clone your fork
- Run in the base repo:
python setup.py develop && pip install -r requirements-test.txt
- Context managers can be used to timeout code blocks if they reach a certain elapsed amount of time specified by the user
- The same type of functionality can be used as a wrapper for functions
Use it to timeout a block of code after a certain amount of elapsed time
import timeout
# Timeout this code block after 10 seconds has elapsed
with timeout.of(10):
result = some_complex_stuff()
some_more_complex_stuff(result)
Wrap functions that take a long time to do stuff and make sure they timeout correctly
import timeout
# Set some_complex_stuff to timeout after 10 seconds has elapsed
@timeout.after(10)
def some_complex_stuff():
# Execute some complex behavior
some_complex_stuff()
- Fork the repo
- Commit changes to your Fork
- Run
python setup.py test
and make sure those all pass - Submit those changes as a Pull Request!