Commit b322ada0 authored by Chris McDonough's avatar Chris McDonough

Removed unnecessary imports. Removed some debugging code. Tests now pass on Cygwin.

parent adfa2e91
......@@ -85,13 +85,13 @@
"""
Transient Object Container class.
$Id: Transience.py,v 1.21 2001/11/21 22:46:36 chrism Exp $
$Id: Transience.py,v 1.22 2001/11/26 15:29:26 chrism Exp $
"""
__version__='$Revision: 1.21 $'[11:-2]
__version__='$Revision: 1.22 $'[11:-2]
import Globals
from Globals import HTMLFile, MessageDialog
from Globals import HTMLFile
from TransienceInterfaces import ItemWithId,\
StringKeyedHomogeneousItemContainer, TransientItemContainer
from TransientObject import TransientObject
......@@ -99,12 +99,11 @@ from OFS.SimpleItem import SimpleItem
from Persistence import Persistent
from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager
import AccessControl.SpecialUsers
from AccessControl.User import nobody
from BTrees import OOBTree
from BTrees.Length import Length
from zLOG import LOG, WARNING, BLATHER
import os, os.path, math, time, sys, random
import os, math, time, sys, random
DEBUG = os.environ.get('Z_TOC_DEBUG', '')
......@@ -408,12 +407,11 @@ class TransientObjectContainer(SimpleItem):
try: self.__len__.set(0)
except AttributeError: self.__len__ = self.getLen = Length()
def _getCurrentBucket(self, get_dump=0):
def _getCurrentBucket(self):
# no timeout always returns last bucket
if not self._timeout_secs:
DEBUG and DLOG('no timeout, returning first bucket')
b, dump_after = self._ring._data[0]
if DEBUG:
DLOG('no timeout, returning first bucket')
return b
index = self._ring._index
now = int(time.time())
......@@ -425,9 +423,8 @@ class TransientObjectContainer(SimpleItem):
while 1:
l = b, dump_after = self._ring._data[-1]
if now > dump_after:
if DEBUG:
DLOG('now is %s' % now)
DLOG('dump_after for %s was %s, dumping'%(b, dump_after))
DEBUG and DLOG('dumping... now is %s' % now)
DEBUG and DLOG('dump_after for %s was %s'%(b, dump_after))
self._ring.turn()
# mutate elements in-place in the ring
new_dump_after = now + i
......@@ -437,9 +434,6 @@ class TransientObjectContainer(SimpleItem):
else:
break
if to_clean: self._clean(to_clean, index)
if get_dump:
return self._ring._data[0], dump_after, now
else:
b, dump_after = self._ring._data[0]
return b
......@@ -474,20 +468,6 @@ class TransientObjectContainer(SimpleItem):
# finalize em
self.notifyDestruct(trans_obs)
def _show(self):
""" debug method """
b,dump,now = self._getCurrentBucket(1)
ringdumps = map(lambda x: `x[1]`[-4], self._ring)
t = (
"now: "+`now`[-4:],
"dump_after: "+`dump`[-4:],
"ring_dumps: "+`ringdumps`,
"ring: " + `self._ring`
)
for x in t:
print x
security.declareProtected(MGMT_SCREEN_PERM, 'nudge')
def nudge(self):
""" Used by mgmt interface to turn the bucket set each time
......
......@@ -85,13 +85,13 @@
"""
Simple ZODB-based transient object implementation.
$Id: TransientObject.py,v 1.1 2001/11/21 22:46:36 chrism Exp $
$Id: TransientObject.py,v 1.2 2001/11/26 15:29:27 chrism Exp $
"""
__version__='$Revision: 1.1 $'[11:-2]
__version__='$Revision: 1.2 $'[11:-2]
from Persistence import Persistent
from Acquisition import Implicit, aq_base
from Acquisition import Implicit
import time, random, sys
from TransienceInterfaces import ItemWithId, Transient, DictionaryLike,\
TTWDictionary, ImmutablyValuedMappingOfPickleableObjects
......
......@@ -384,7 +384,7 @@ class TestTransientObjectContainer(TestCase):
self.t._reset()
for x in range(10, 110):
self.t[x] = x
fauxtime.sleep(self.timeout * (self.errmargin+1))
fauxtime.sleep(self.timeout)
assert len(self.t.keys()) == 100, len(self.t.keys())
fauxtime.sleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 0, len(self.t.keys())
......@@ -394,9 +394,9 @@ class TestTransientObjectContainer(TestCase):
self.t._reset()
for x in range(10, 110):
self.t[x] = x
fauxtime.sleep(self.timeout * (self.errmargin+1))
fauxtime.sleep(self.timeout)
assert len(self.t.keys()) == 100, len(self.t.keys())
fauxtime.sleep(self.timeout * (self.errmargin+1))
fauxtime.sleep(self.timeout)
assert len(self.t.keys()) == 100, len(self.t.keys())
fauxtime.sleep(self.timeout * (self.errmargin+1))
assert len(self.t.keys()) == 0, len(self.t.keys())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment