[Zope-Checkins] CVS: Zope/lib/python/Products/Transience - Transience.py:1.32.12.2.2.2

Chris McDonough chrism at plope.com
Sun Feb 29 15:15:49 EST 2004


Update of /cvs-repository/Zope/lib/python/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv2628

Modified Files:
      Tag: chrism-sessiongeddon
	Transience.py 
Log Message:
Deal with timeouts set to 0 (persist forever).


=== Zope/lib/python/Products/Transience/Transience.py 1.32.12.2.2.1 => 1.32.12.2.2.2 ===
--- Zope/lib/python/Products/Transience/Transience.py:1.32.12.2.2.1	Sun Feb 29 03:42:48 2004
+++ Zope/lib/python/Products/Transience/Transience.py	Sun Feb 29 15:15:48 2004
@@ -54,7 +54,6 @@
 ACCESS_TRANSIENTS_PERM = 'Access Transient Objects'
 MANAGE_CONTAINER_PERM = 'Manage Transient Object Container'
 
-
 PERIOD = 20 # attempt housekeeping every PERIOD seconds
 SPARE_BUCKETS = 15 # number of buckets to keep spare
 STRICT = os.environ.get('Z_TOC_STRICT', '')
@@ -62,6 +61,8 @@
 
 _marker = []
 
+
+
 def setStrict(on=''):
     """ Turn on assertions (which may cause conflicts) """
     global STRICT
@@ -187,8 +188,17 @@
         except AttributeError: self.__len__ = self.getLen = Length()
 
     def _getCurrentSlices(self, now):
-        begin = now+PERIOD - (PERIOD * self._timeout_slices)
-        return getTimeslices(begin, self._timeout_slices)
+        if self._timeout_slices:
+            begin = now+PERIOD - (PERIOD * self._timeout_slices)
+            num_slices = self._timeout_slices
+        else:
+            begin = STARTUP_SLICE
+            num_slices = (now / PERIOD) - (STARTUP_SLICE / PERIOD)
+        DEBUG and TLOG('_getCurrentSlices, begin = %s' % begin)
+        DEBUG and TLOG('_getCurrentSlices, num_slices = %s' % num_slices)
+        result = getTimeslices(begin, num_slices)
+        DEBUG and TLOG('_getCurrentSlices, result = %s' % result)
+        return result
 
     def _move_item(self, k, current_ts, default=None):
         if self._roll(current_ts, 'replentish'):
@@ -406,6 +416,9 @@
             self._max_timeslice.set(max(new_buckets))
 
     def _gc(self, now=None):
+        if self._timeout_slices == 0:
+            return # dont do gc if there is no timeout
+
         if now is None:
             now = getCurrentTimeslice() # for unit tests
         max_ts = now  - (PERIOD * (self._timeout_slices + 1))
@@ -629,5 +642,7 @@
 
     def _p_independent(self):
         return 1
+
+STARTUP_SLICE = getCurrentTimeslice()
 
 Globals.InitializeClass(TransientObjectContainer)




More information about the Zope-Checkins mailing list