code: def _extract_reason(kw):
      
      try:
          # we "often" have a REASON
          reason = kw['REASON']
          try:
              # ...and sometimes even have a REMOTE_REASON
              reason = '{}, {}'.format(reason, kw['REMOTE_REASON'])
          except KeyError:
              pass  # should still be the 'REASON' error if we had it
      except KeyError:
          reason = "unknown"
      return reason
docs: Internal helper. Extracts a reason (possibly both reasons!) from
      the kwargs for a circuit failed or closed event.