(get_doc_ids, min_tries, limit=None)
return missing, limit
Find missing ids

    Given a function that is expected to always return the same set of
    unique ids, find all ids that are missing from some result sets.

    Returns a tuple `(missing_ids, tries)`
Find missing ids
Find missing ids
def find_missing_ids(get_doc_ids, min_tries, limit=None):
    """Find missing ids

    Given a function that is expected to always return the same set of
    unique ids, find all ids that are missing from some result sets.

    Returns a tuple `(missing_ids, tries)`
    """
    if min_tries < 2:
        raise ValueError("min_tries must be greater than 1")
    limit = limit or min_tries * 20
    min_tries -= 1
    missing = set()
    all_ids = set()
    no_news = 1
    for tries in range(limit):
        next_ids = get_doc_ids()
        if all_ids:
            miss = next_ids ^ all_ids
            if any(x not in missing for x in miss):
                no_news = 1
                missing.update(miss)
                all_ids.update(miss)
        else:
            all_ids.update(next_ids)
        if no_news > min_tries:
            return missing, tries + 1
        no_news += 1
    log.warning(f"still finding new missing docs after {limit} queries")
    return missing, limit
def find_missing_ids ( get_doc_ids , min_tries , limit = None ) : if min_tries < 2 : raise ValueError ( "min_tries must be greater than 1" ) limit = limit or min_tries * 20 min_tries -= 1 missing = set ( ) all_ids = set ( ) no_news = 1 for tries in range ( limit ) : next_ids = get_doc_ids ( ) if all_ids : miss = next_ids ^ all_ids if any ( x not in missing for x in miss ) : no_news = 1 missing . update ( miss ) all_ids . update ( miss ) else : all_ids . update ( next_ids ) if no_news > min_tries : return missing , tries + 1 no_news += 1 log . warning ( f"still finding new missing docs after {limit} queries" ) return missing , limit