# Pastebin 3nUI9FdP import sys import gc import weakref class A: pass def demo(): v = yield lst = [] v = weakref.ref(v, lambda _: lst.append(True)) while not lst: gc.collect() d = demo() d.send(None) d.send(A())