1 from functools
import wraps
9 def timeout(seconds=10, error_message=os.strerror(errno.ETIME)):
11 def _handle_timeout(signum, frame):
12 raise TimeoutError(error_message)
14 def wrapper(*args, **kwargs):
15 signal.signal(signal.SIGALRM, _handle_timeout)
18 result = func(*args, **kwargs)
23 return wraps(func)(wrapper)
def timeout(seconds=10, error_message=os.strerror(errno.ETIME))