Skip to content

Commit

Permalink
- prevent errors due to changed behaviors in Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Oct 14, 2019
1 parent 188f56b commit 5de3891
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Products/StandardCacheManagers/RAMCacheManager.py
Expand Up @@ -202,8 +202,8 @@ def deleteEntriesAtOrBelowThreshold(self, threshold_access_count):
"""
self.writelock.acquire()
try:
for p, oc in self.cache.items():
for agindex, entry in oc.entries.items():
for p, oc in list(self.cache.items()):
for agindex, entry in list(oc.entries.items()):
if entry.access_count <= threshold_access_count:
del oc.entries[agindex]
if len(oc.entries) < 1:
Expand All @@ -219,8 +219,8 @@ def deleteStaleEntries(self):
self.writelock.acquire()
try:
min_created = time.time() - self.max_age
for p, oc in self.cache.items():
for agindex, entry in oc.entries.items():
for p, oc in list(self.cache.items()):
for agindex, entry in list(oc.entries.items()):
if entry.created < min_created:
del oc.entries[agindex]
if len(oc.entries) < 1:
Expand All @@ -236,11 +236,10 @@ def cleanup(self):
new_count = self.countAllEntries()
if new_count > self.threshold:
counters = self.countAccesses()
priorities = counters.items()
priorities = sorted(counters.items())
# Remove the least accessed entries until we've reached
# our target count.
if len(priorities) > 0:
priorities.sort()
access_count = 0
for access_count, effect in priorities:
new_count = new_count - effect
Expand Down Expand Up @@ -286,7 +285,7 @@ def ZCache_invalidate(self, ob):
# Invalidates all subobjects as well.
self.writelock.acquire()
try:
for p, oc in self.cache.items():
for p, oc in list(self.cache.items()):
pp = oc.physical_path
if pp[:len(path)] == path:
del self.cache[p]
Expand Down

0 comments on commit 5de3891

Please sign in to comment.