[Zope-Checkins] CVS: Products/Transience -
Transience.py:1.32.12.8.2.5
Chris McDonough
chrism at plope.com
Mon Sep 13 11:31:22 EDT 2004
Update of /cvs-repository/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv22213
Modified Files:
Tag: chrism-pre273-branch
Transience.py
Log Message:
Add _in_emergency_bucket_shortage method (fix caller too).
=== Products/Transience/Transience.py 1.32.12.8.2.4 => 1.32.12.8.2.5 ===
--- Products/Transience/Transience.py:1.32.12.8.2.4 Mon Sep 13 11:19:51 2004
+++ Products/Transience/Transience.py Mon Sep 13 11:31:22 2004
@@ -281,11 +281,7 @@
else:
# dont allow the TOC to stop working in an emergency bucket
# shortage
- max_ts = self._max_timeslice()
- low = now/self._period
- high = max_ts/self._period
- required = high <= low
- if required:
+ if self._in_emergency_bucket_shortage(current_ts):
self._replentish(current_ts)
# SUBTLETY ALERTY TO SELF: do not "improve" the code below
@@ -360,7 +356,7 @@
if self._inband_housekeeping:
self._housekeep(current_ts)
- elif self._in_emergency_bucket_shortage(current_ts)[0]:
+ elif self._in_emergency_bucket_shortage(current_ts):
# if our scheduler fails, dont allow the TOC to stop working
self._replentish(current_ts, force=True)
@@ -507,6 +503,13 @@
def _get_max_expired_ts(self, now):
return now - (self._period * (self._timeout_slices + 1))
+ def _in_emergency_bucket_shortage(self, now):
+ max_ts = self._max_timeslice()
+ low = now/self._period
+ high = max_ts/self._period
+ required = high <= low
+ return required
+
def _finalize(self, now):
""" Call finalization handlers for the data in each stale bucket """
if not self._timeout_slices:
@@ -603,17 +606,13 @@
DEBUG and TLOG('_replentish: no timeout, doing nothing')
return
- max_ts = self._max_timeslice()
- low = now/self._period
- high = max_ts/self._period
-
# the difference between high and low naturally diminishes to
# zero as now approaches self._max_timeslice() during normal
# operations. If high <= low, it means we have no current bucket,
# so we *really* need to replentish (having a current bucket is
# an invariant for continued operation).
- required = high <= low
+ required = self._in_emergency_bucket_shortage(now)
lock_acquired = self.replentish_lock.acquire(0)
try:
@@ -626,6 +625,7 @@
DEBUG and TLOG('_replentish: required, lock acquired)')
else:
DEBUG and TLOG('_replentish: required, lock NOT acquired)')
+ max_ts = self._max_timeslice()
self._do_replentish_work(now, max_ts)
elif lock_acquired:
@@ -635,6 +635,9 @@
# introducing a random element.
DEBUG and TLOG('_replentish: attempting optional replentish '
'(lock acquired)')
+ max_ts = self._max_timeslice()
+ low = now/self._period
+ high = max_ts/self._period
if roll(low, high, 'optional replentish'):
self._do_replentish_work(now, max_ts)
@@ -1034,8 +1037,8 @@
class Increaser(Persistent):
"""
A persistent object representing a typically increasing integer that
- has conflict resolution uses the greatest integer out of the three
- available states
+ has conflict resolution which uses the greatest integer out of the three
+ available states.
"""
def __init__(self, v):
self.value = v
More information about the Zope-Checkins
mailing list