code: def graceful(cls):
      
      def _wrapper(f):
          @functools.wraps(f)
          def __wrapper(msg, **config):
              try:
                  return f(msg, **config)
              except KeyError:
                  log.exception("%r failed on %r" % (f, msg.get('msg_id')))
                  return cls()
  
          return __wrapper
      return _wrapper
docs: A decorator to protect against message structure changes.
  
      Many of our processors expect messages to be in a certain format.  If the
      format changes, they may start to fail and raise exceptions.  This decorator
      is in place to catch and log those exceptions and to gracefully return
      default values.