(kw)
return reason
Internal helper. Extracts a reason (possibly both reasons!) from
    the kwargs for a circuit failed or closed event.
Internal helper. Extracts a reason (possibly both reasons!) from
    the kwargs for a circuit failed or closed event.
Internal helper . Extracts a reason ( possibly both reasons! ) from the kwargs for a circuit failed or closed event .
def _extract_reason(kw):
    """
    Internal helper. Extracts a reason (possibly both reasons!) from
    the kwargs for a circuit failed or closed event.
    """
    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
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