code: def fail_on_stopiteration(f):
      
      def wrapper(*args, **kwargs):
          try:
              return f(*args, **kwargs)
          except StopIteration as exc:
              raise RuntimeError(
                  "Caught StopIteration thrown from user's code; failing the task",
                  exc
              )
  
      return wrapper
docs: Wraps the input function to fail on 'StopIteration' by raising a 'RuntimeError'
      prevents silent loss of data when 'f' is used in a for loop in Spark code