[Zope-CVS] CVS: Products/Scheduler - Scheduler.py:1.22
Chris McDonough
chrism@zope.com
Mon, 7 Jul 2003 17:47:38 -0400
Update of /cvs-repository/Products/Scheduler
In directory cvs.zope.org:/tmp/cvs-serv25325
Modified Files:
Scheduler.py
Log Message:
Dont fail in deschedule if btrees get out of sync.
=== Products/Scheduler/Scheduler.py 1.21 => 1.22 ===
--- Products/Scheduler/Scheduler.py:1.21 Mon Jul 7 17:31:50 2003
+++ Products/Scheduler/Scheduler.py Mon Jul 7 17:47:33 2003
@@ -292,12 +292,28 @@
def deschedule(self, taskid):
""" deschedule the task by removing from the tasks and times BTrees """
time = int(taskid[:10])
- del self.tasks[taskid]
- l = self.times[time]
- l.remove(taskid)
+ try:
+ del self.tasks[taskid]
+ except KeyError:
+ # an inconsistency occurred between the tasks and times
+ # btrees or the taskid is bogus
+ LOG('Scheduler (%s)' % self.getId(), ERROR,
+ 'a task with taskid %s could not be removed from the tasks '
+ 'btree' % taskid)
+ l = self.times.get(time)
+ try:
+ l.remove(taskid)
+ except (ValueError, IndexError, KeyError):
+ # an inconsistency occurred between the tasks and times
+ # btrees or the times entry is bogus
+ LOG('Scheduler (%s)' % self.getId(), ERROR,
+ 'taskid %s could not be removed from the time list for time '
+ '%s' % (taskid, time))
if l:
+ # a nonempty list
self.times[time] = l
- else:
+ elif l is not None:
+ # an empty list
del self.times[time]
security.declareProtected(CHANGE_SCHEDULE_PERM, 'checkConsistency')