def get_case_groups_in_domain(domain, limit=None, skip=None):
    def _get_case_groups_generator(domain_name):
        for case_group in get_docs_in_domain_by_class(domain_name, CommCareCaseGroup):
            yield case_group

    case_groups_generator = _get_case_groups_generator(domain)

    if skip is not None:
        try:
            for _ in range(skip):
                next(case_groups_generator)
        except __HOLE__:
            pass

    if limit is not None:
        return list(next(case_groups_generator) for _ in range(limit))
    return list(case_groups_generator)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/casegroups/dbaccessors.py/get_case_groups_in_domain