Commit 66592930 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #590 from kmod/weakref4

Try to make weakref4 less flaky
parents aad3f44e 15bf644d
...@@ -13,7 +13,10 @@ def recurse(f, n): ...@@ -13,7 +13,10 @@ def recurse(f, n):
return f() return f()
w = recurse(doStuff, 100) l1 = []
for i in xrange(5):
w = recurse(doStuff, 100)
l1.append(w)
# Try creating a large object to make sure we can handle them: # Try creating a large object to make sure we can handle them:
def f(): def f():
...@@ -22,10 +25,12 @@ def f(): ...@@ -22,10 +25,12 @@ def f():
__slots__ = ['a' + str(i) for i in xrange(1000)] __slots__ = ['a' + str(i) for i in xrange(1000)]
return weakref.ref(C) return weakref.ref(C)
l2 = []
r = recurse(f, 100) for i in xrange(5):
r = recurse(f, 100)
l2.append(r)
import gc import gc
gc.collect() gc.collect()
assert r() is None, "object was not collected" assert any(r() is None for r in l2), "object was not collected"
assert w() is None, "object was not collected" assert any(w() is None for w in l1), "object was not collected"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment