[Zope3-dev] Intermittent failures in WeakRef doctest

Dave Harris dpharris76 at msn.com
Sat Jan 24 14:04:41 EST 2004


A week ago, I reported intermittent failures of the WeakRef doctest.

(http://mail.zope.org/pipermail/zope3-dev/2004-January/009431.html)

I didn't get any advice on my testing process, so I set it aside for a 
while. After all, I was overjoyed to get the unit tests running cleanly 
under Windows XP.

But still, every now and then, the WeakRef failure pops up, spoiling my 
perfect score. Today, I dug a little deeper and distilled the doctest from 
wref.py into a looping script (see below.)

Under Windows XP, the failure rate is about 65%. That is, the dereference 
returns None about 35% of the time and an empty list '[]' about 65% of the 
time.

I'm still gathering information about the internal goings-on, and I'll pass 
along what I find.

"What is my quest? I seek the fragile WeakRef!"
Dave Harris

Here's the script:

# wref test based on wref.py doctest
# 2004-01-24

import persistence.list
from persistence.wref import WeakRef
import zodb.tests.util

nones = 0
lists = 0

for i in range(100):
    ob = persistence.list.PersistentList()
    ref = WeakRef(ob)

    db = zodb.tests.util.DB()

    conn1 = db.open()
    r1 = conn1.root()
    r1['ob'] = ob
    r1['ref'] = ref
    zodb.tests.util.commit()

    del r1['ob']
    zodb.tests.util.commit()
    zodb.tests.util.pack(db)

    conn3 = db.open()
    r3 = conn3.root()

    if r3['ref']() == None:
        nones += 1
    else:
        lists += 1

    db.close()

print "ref() == None %s times, ref() == [] %s times" % (nones, lists) 



More information about the Zope3-dev mailing list