Created
February 27, 2017 23:19
-
-
Save jan-matejka/519559fc9fc16a71699de6deb32d5c0f 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 weakref | |
| import gc | |
| class Foo: | |
| def __init__(self, factory): | |
| self.factory = factory | |
| class Factory: | |
| def mk_foo(self): | |
| self.foo = Foo(self) | |
| return self.foo | |
| def test_me(): | |
| f = Factory() | |
| foo = weakref.proxy(f.mk_foo()) | |
| del f | |
| gc.collect() | |
| print(str(foo)) | |
| if __name__ == "__main__": | |
| test_me() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment