[Checkins] SVN: zc.async/trunk/src/zc/async/ Quotas should not use containers with conflict resolution!
Gary Poster
gary at modernsongs.com
Thu Aug 21 23:12:19 EDT 2008
Log message for revision 90109:
Quotas should not use containers with conflict resolution!
Changed:
U zc.async/trunk/src/zc/async/CHANGES.txt
U zc.async/trunk/src/zc/async/queue.py
-=-
Modified: zc.async/trunk/src/zc/async/CHANGES.txt
===================================================================
--- zc.async/trunk/src/zc/async/CHANGES.txt 2008-08-22 03:11:47 UTC (rev 90108)
+++ zc.async/trunk/src/zc/async/CHANGES.txt 2008-08-22 03:12:19 UTC (rev 90109)
@@ -22,10 +22,13 @@
- Fix retry behavior for parallel and serial jobs XXX NEEDS TEST
-- tweaked the uuid.txt to mention zdaemon/supervisor rather than Zope 3.
+- Tweaked the uuid.txt to mention zdaemon/supervisor rather than Zope 3.
-- fixed some bugs in egg creation
+- Fixed some bugs in egg creation
+- Changed quotas to not use a container that has conflict resolution, since
+ these values should be a strict maximum.
+
1.4.1 (2008-07-30)
==================
Modified: zc.async/trunk/src/zc/async/queue.py
===================================================================
--- zc.async/trunk/src/zc/async/queue.py 2008-08-22 03:11:47 UTC (rev 90108)
+++ zc.async/trunk/src/zc/async/queue.py 2008-08-22 03:12:19 UTC (rev 90109)
@@ -209,23 +209,32 @@
class Quota(zc.async.utils.Base):
+ # this implementation is reasonable for relatively small (say, size<100)
+ # quotas.
zope.interface.implements(zc.async.interfaces.IQuota)
+ _data = ()
+
def __init__(self, name, size):
- self._data = zc.queue.Queue()
self.name = name
self.size = size
def clean(self):
now = datetime.datetime.now(pytz.UTC)
- for i, job in enumerate(reversed(self._data)):
+ changed = False
+ new = []
+ for job in self._data:
status = job.status
if status in (zc.async.interfaces.CALLBACKS,
zc.async.interfaces.COMPLETED) or (
status == zc.async.interfaces.PENDING and
job.begin_after > now): # for a rescheduled task
- self._data.pull(-1-i)
+ changed = True # remove from quota
+ else:
+ new.append(job)
+ if changed:
+ self._data = tuple(new)
@property
def filled(self):
@@ -246,7 +255,8 @@
raise ValueError('quota name must be in quota_names')
if self.filled:
raise ValueError('Quota is filled')
- self._data.put(item)
+ # casting self._data to tuple for legacy instances; no-op for tuples
+ self._data = tuple(self._data) + (item,)
for nm in ('__len__', '__iter__', '__getitem__', '__nonzero__', 'get'):
locals()[nm] = zc.async.utils.simpleWrapper(nm)
More information about the Checkins
mailing list