Mailing List Archive

Bug in ZSQL method result caching?
Hi All,

I'm seeing a fair few errors as follows using Zope 2.8.4:

results = self.aZSQLMethod(p1=value1, p2=value2)
File "lib/python/Shared/DC/ZRDB/DA.py",line 453, in __call__
result=self._cached_result(DB__, (query, self.max_rows_))
File "lib/python/Shared/DC/ZRDB/DA.py",line 375, in _cached_result
if int(cache[q][0]) == key:
KeyError: ("execute dbo.aStoredProcedure 'VALUE1', 'VALUE2'\n",
1000,
'\nDBConnId: None')

The code in question is this, from DA.py:

# Try to fetch from cache
if hasattr(self,'_v_cache'): cache=self._v_cache
else: cache=self._v_cache={}, Bucket()
cache, tcache = cache
max_cache=self.max_cache_
now=time()
t=now-self.cache_time_
if len(cache) > max_cache / 2:
keys=tcache.keys()
keys.reverse()
while keys and (len(keys) > max_cache or keys[-1] < t):
key=keys[-1]
q=tcache[key]
del tcache[key]
if int(cache[q][0]) == key:
del cache[q]
del keys[-1]


The if clause seems a bit dodgy...

Is that while loop maybe iterating over a mutable object while deleting
stuff from it?

I'm only stabbing in the dark here...

Does anyone have any better ideas?

cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db