import gc
import kaa
@kaa.yield_execution()
def foo():
yield kaa.YieldContinue
crash
@kaa.yield_execution()
def bar():
yield foo()
print 'unreached but ok'
def garbage_collect():
gc.collect()
for g in gc.garbage:
# print information about garbage gc can't collect
print 'Unable to free %s' % (g,)
bar()
# if you add a __del__ to InProgress you will see a message that
# YieldFunction can not be freed. So gc detects it. Without a
# __del__ it is still a circular ref, but you will see nothing.
# Why is the object not freed? Or is it and weakref callback is
# not working?
kaa.Timer(garbage_collect).start(0.5)
kaa.main.run()