def filter_preconditions(classes, logger=None):
    """Filter handlers whose preconditions are not met

    classes: list of nogotofail handler classes to filter
    logger: logging.Logger to optionally log the failure message of handlers whose preconditions are not met.
    Returns list of classes whose preconditions are met
    """
    filtered = []
    for cls in classes:
        status, message = cls.check_precondition()
        if status:
            filtered.append(cls)
        elif logger is not None:
            logger.warning("Disabling handler %s because preconditions not met: %s.", cls.name, message)
    return filtered
Filter handlers whose preconditions are not met

    classes: list of nogotofail handler classes to filter
    logger: logging.Logger to optionally log the failure message of handlers whose preconditions are not met.
    Returns list of classes whose preconditions are met
    
nogotofail/mitm/connection/handlers/preconditions.py