Skip to content

Instantly share code, notes, and snippets.

@jan-matejka
Created February 27, 2017 23:19
Show Gist options
  • Select an option

  • Save jan-matejka/519559fc9fc16a71699de6deb32d5c0f to your computer and use it in GitHub Desktop.

Select an option

Save jan-matejka/519559fc9fc16a71699de6deb32d5c0f to your computer and use it in GitHub Desktop.
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