Created on 2017-03-20.21:39:42 by jamesmudd, last changed 2017-03-21.03:49:33 by zyasoft.
|msg11255 (view)||Author: James Mudd (jamesmudd)||Date: 2017-03-20.21:39:41|
I have observed test_weakref fail a few times while running ant regrtest. The output is: [exec] test test_weakref failed -- Traceback (most recent call last): [exec] File "/home/james/git/jython/dist/Lib/test/test_weakref.py", line 1029, in test_weak_values [exec] self.assertEqual(len(list(dict.iterkeys())), 0, [exec] AssertionError: deleting the values did not clear the dictionary The failure appears to be intermittent, I haven't reproduced it when running the test individually, and I have never observed it on Windows.
|msg11258 (view)||Author: Jim Baker (zyasoft)||Date: 2017-03-21.03:49:33|
So our assumption on these sorts of testing bugs is that multiple phases of GC are often required to clear out weak references; and GC in general is never quite as deterministic as we would like for such testing. (CPython's model in contrast does give us deterministic GC, so it's a bit harder to use the same tests. In practice, it would not matter - one should not rely on determinism in GC even in CPython, given the possibility of cycles.) You can see the specific code used in the extra_collect function. In particular, test_weak_values does not use the extra_collect function; it instead uses gc.collect directly. It would be worthwhile revisiting with extra_collect here to see if it makes a difference. Note that if the weakref is never collected, that would be a bug!
messages: + msg11258