docs: def fallback(func):
      """ Decorator function for functions that handle spark context.
      If a function changes sc we might lose it if an error occurs in the function.
      In the event of an error this decorator will log the error but return sc.
  
      :param func: function to decorate
      :return: decorated function
      """
      @wraps(func)
      def dec(*args, **kwargs):
          try:
              return func(*args, **kwargs)
          except Exception as e:
              logging.getLogger('pySparkUtils').error('Decorator handled exception %s' % e, exc_info=True)
              _, _, tb = sys.exc_info()
              while tb.tb_next:
                  tb = tb.tb_next
                  frame = tb.tb_frame
                  for key, value in iteritems(frame.f_locals):
                      if isinstance(value, SparkContext) and value._jsc is not None:
                          return frame.f_locals[key]
              logging.getLogger('pySparkUtils').error('Could not find SparkContext', exc_info=True)
              return None
  
      return dec