I know this should be a classic welcome post but, there is few errors you need to solve before you sleep:

import weakref

class Foo(object):

def callback(x):
    del lst[:]

keepalive = []

for i in range(100):
    lst = [str(i)]
    foo = Foo()
    foo.cycle = foo

    keepalive.append(weakref.ref(foo, callback))

    del foo

    while lst:

As @someone said,

Debugging is twice as hard as writing the code in the first place. Therefore, if...