Skip to content

Instantly share code, notes, and snippets.

@lqc
Created October 31, 2011 22:33
Show Gist options
  • Save lqc/1329247 to your computer and use it in GitHub Desktop.
Save lqc/1329247 to your computer and use it in GitHub Desktop.
import gc
gc.set_debug(gc.DEBUG_UNCOLLECTABLE | gc.DEBUG_STATS)
class CallbackTest (object):
def __init__(self):
self.my_callback = lambda :None
def signal(self):
self.my_callback()
class App (object):
def __init__(self):
self.test = CallbackTest()
self.test.my_callback = self.on_signal
self.test.signal()
def on_signal(self):
print "Hello!"
App()
Hello!
gc: collecting generation 2...
gc: objects in each generation: 97 3117 0
gc: done, 5 unreachable, 0 uncollectable, 0.0015s elapsed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment