Timeout Decorator
Updated Oct 28, 2019 ·
Problem
Some functions can run too long or hang indefinitely. We want a way to stop them if they exceed a certain time limit.
Solution
Create a timeout decorator that stops a function if it runs longer than the allowed time.
The decorator can use Python's signal module to raise a TimeoutError when the function takes too long. It can also be customized to allow different timeouts for different functions.
The full code can be found here: Github repo