[Zope-CVS] CVS: Products/Scheduler - Scheduler.py:1.11

Ken Manheimer klm@zope.com
Tue, 13 May 2003 19:32:21 -0400


Update of /cvs-repository/Products/Scheduler
In directory cvs.zope.org:/tmp/cvs-serv4831

Modified Files:
	Scheduler.py 
Log Message:
Provide for infinite max_age and max_retries, when they are set to zero.

.clone(): use explicit keyword arguments so we don't get
argument-order mismatch.


=== Products/Scheduler/Scheduler.py 1.10 => 1.11 ===
--- Products/Scheduler/Scheduler.py:1.10	Tue May 13 11:29:14 2003
+++ Products/Scheduler/Scheduler.py	Tue May 13 19:32:21 2003
@@ -135,8 +135,8 @@
 
     security.declareProtected(NOTIFY_SCHEDULE_PERM, 'notify')
     def notify(self, event=None):
-        """
-        If it is specified, 'event' must be a "time event" or a
+
+        """If it is specified, 'event' must be a "time event" or a
         "schedule event".
 
         A time event may be signified by any of the following objects:
@@ -154,8 +154,8 @@
 
         A schedule event is an object that implements the IScheduledEvent
         interface.  When we receive a schedule event, we schedule the
-        event but we do not actually process the event queue.
-        """
+        event but we do not actually process the event queue."""
+
         LOG('Scheduler', BLATHER, 'notify called')
         if event is None:
             # If event is None, assume that we want to run tasks before
@@ -241,10 +241,10 @@
         """
             Return a sequence of mappings for use by UI.
         """
-        return [ ( x[0], { 'when' : x[1].getTime()
-                       , 'info' : x[1].getInfo()
-                       , 'description' : x[1].getDescription() } )
-                 for x in self.getPendingTasks( when ) ]
+        return [(x[0], {'when': x[1].getTime(),
+                        'info': x[1].getInfo(),
+                        'description': x[1].getDescription()})
+                for x in self.getPendingTasks(when)]
 
     security.declareProtected(CHANGE_SCHEDULE_PERM, 'schedule')
     def schedule(self, time, task):
@@ -340,7 +340,7 @@
 
         now = int(time.time())
         # secondary max_age guard (in case of clock failure)
-        if now > self.when + self.max_age:
+        if self.max_age and (now > self.when + self.max_age):
             msg = ('Task "%s" scheduled for %s failed due to exceeded maximum '
                    'age - not rescheduling'
                    % (self.getDescription(), pretty_time(self.when)))
@@ -359,7 +359,7 @@
             exc_name = exc_msg = exc_tb = None
 
             # retry guard
-            if (self.retries + 1) > self.max_retries:
+            if self.max_retries and ((self.retries + 1) > self.max_retries):
                 msg = ('Task "%s" scheduled for %s failed on exception'
                        '- not rescheduling due to exceeded maximum retries.'
                        '  Exception: %s'
@@ -370,7 +370,7 @@
             then = now + self.retry_backoff_time
 
             # primary max_age guard
-            if then > self.when + self.max_age:
+            if self.max_age and (then > self.when + self.max_age):
                 msg = ('Task "%s" scheduled for %s failed on exception'
                        ' - not rescheduling due to exceeded maximum age'
                        '  Exception: %s'
@@ -440,14 +440,14 @@
 
     def clone(self, when):
         LOG('Scheduler', BLATHER, 'clone called')
-        return self.__class__(self.description,
-                              when,
-                              self.path,
-                              self.interval,
-                              self.max_age,
-                              self.max_retries,
-                              self.retry_backoff_time,
-                              self.filter_data)
+        return self.__class__(description=self.description,
+                              when=when,
+                              path=self.path,
+                              interval=self.interval,
+                              max_age=self.max_age,
+                              max_retries=self.max_retries,
+                              retry_backoff_time=self.retry_backoff_time,
+                              filter_data=self.filter_data)
 
 class Filter(Base, Persistent):
     def __init__(self, key):