Created
October 31, 2011 22:33
-
-
Save lqc/1329247 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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