def get_leaking_objects(objects=None):
    if objects is None:
        gc.collect()
        objects = gc.get_objects()
    try:
        ids = set(id(i) for i in objects)
        for i in objects:
            ids.difference_update(id(j) for j in gc.get_referents(i))
        # this then is our set of objects without referrers
        return [i for i in objects if id(i) in ids]
    finally:
        del objects, i  # clear cyclic references to frame
Return objects that do not have any referents.
dataset/ETHPy150Open Exa-Networks/exabgp/lib/exabgp/dep/objgraph.py/get_leaking_objects