def _run_finalizer(ref):
    """Internal weakref callback to run finalizers"""
    del _finalize_refs[id(ref)]
    finalizer = ref.finalizer
    item = ref.item
    try:
        finalizer(item)
    except Exception:
        print("Exception running {}:".format(finalizer), file=sys.stderr)
        traceback.print_exc()
Internal weakref callback to run finalizers
recipes/Python/577242_Calling_Clevel_finalizers_without/recipe-577242.py