[ZODB-Dev] Re: BTrees strangeness (was [Zope-dev] Zope 2.X BIG Session problems - blocker - our site dies - need help of experience Zope developer, please)

Casey Duncan casey at zope.com
Wed Mar 3 22:20:02 EST 2004


On Wed, 03 Mar 2004 12:44:29 -0500
Jeremy Hylton <jeremy at zope.com> wrote:

> On Wed, 2004-03-03 at 04:55, Chris McDonough wrote:
> > (boldly crossposting this to zodb-dev, please respond on one list or
> > the other but not both)
> > 
> > That error *appears* to be caused by reaching a state that is
> > impossible to reach.  The code in question is:
> > 
> >         for key in list(self._data.keys(None, max_ts)):
> >             assert(key <= max_ts)
> >             STRICT and _assert(self._data.has_key(key))
> >             for v in self._data[key].values():
> >                 to_notify.append(v)
> >             del self._data[key]

Maybe you could use items() and two loops instead;

to_rm = []
for key, val in self._data.items(None, max_ts):
    for v in val.values():
        to_notify.append(v)
    to_rm.append(key)
for key in to_rm:
    try:
        del self._data[key]
    except Keyerror:
       pass # Somebody else deleted it first

I don't think that could raise a KeyError...

-Casey




More information about the ZODB-Dev mailing list