code: def timeout(seconds):
      
      def _timeout_error(signal, frame):
          raise TimeoutError("Operation did not finish within \
          {} seconds".format(seconds))
  
      def timeout_decorator(func):
  
          @wraps(func)
          def timeout_wrapper(*args, **kwargs):
              signal.signal(signal.SIGALRM, _timeout_error)
              signal.alarm(seconds)
              try:
                  return func(*args, **kwargs)
              finally:
                  signal.alarm(0)
  
          return timeout_wrapper
  
      return timeout_decorator
docs: Raises a TimeoutError if a function does not terminate within
      specified seconds.