def test(self): pool = self.pool = ThreadPool(2) refs = [] obj = SomeClass() obj.refs = refs func = obj.func del obj with disabled_gc(): # we do this: # result = func(Object(), kwarg1=Object()) # but in a thread pool and see that arguments', result's and func's references are not leaked result = pool.apply(func, (Object(), ), {'kwarg1': Object()}) assert isinstance(result, Object), repr(result) gevent.sleep(0.1) # XXX should not be needed refs.append(weakref.ref(func)) del func, result if PYPY: gc.collect() gc.collect() for index, r in enumerate(refs): assert r() is None, (index, r(), greentest.getrefcount(r()), refs) assert len(refs) == 4, refs
def test(self): pool = self.pool = ThreadPool(2) refs = [] obj = SomeClass() obj.refs = refs func = obj.func del obj with greentest.disabled_gc(): # we do this: # result = func(Object(), kwarg1=Object()) # but in a thread pool and see that arguments', result's and func's references are not leaked result = pool.apply(func, (Object(), ), {'kwarg1': Object()}) assert isinstance(result, Object), repr(result) gevent.sleep(0.1) # XXX should not be needed refs.append(weakref.ref(func)) del func, result if PYPY: gc.collect() gc.collect() for index, r in enumerate(refs): assert r() is None, (index, r(), greentest.getrefcount(r()), refs) assert len(refs) == 4, refs