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

Ken Manheimer klm@zope.com
Tue, 13 May 2003 11:29:15 -0400


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

Modified Files:
	Scheduler.py 
Log Message:
__call__(): Provide an informative docstring and include information
about the exception in the disposition messages.


=== Products/Scheduler/Scheduler.py 1.9 => 1.10 ===
--- Products/Scheduler/Scheduler.py:1.9	Wed Oct  2 21:54:24 2002
+++ Products/Scheduler/Scheduler.py	Tue May 13 11:29:14 2003
@@ -333,43 +333,57 @@
         self.filter_data = filter_data
 
     def __call__(self):
+        """Run the method on self.path with REQUEST['args'].
+
+        On failure we reschedule, iff max_age and max_retries have not been
+        exceeded."""
+
         now = int(time.time())
         # secondary max_age guard (in case of clock failure)
         if now > self.when + self.max_age:
-            msg = ('Task "%s" scheduled for %s failed due to maximum '
-                   'age exceeded' % (self.getDescription(),
-                                     pretty_time(self.when)))
+            msg = ('Task "%s" scheduled for %s failed due to exceeded maximum '
+                   'age - not rescheduling'
+                   % (self.getDescription(), pretty_time(self.when)))
             LOG('Scheduler', ERROR, msg)
-            return 1 # dont schedule a retry, we've failed
+            return 1
+
         try:
+
             REQUEST = getattr(self, 'REQUEST')
             result = self._runMethod(REQUEST)
+
         except:
+
+            exc_name, exc_msg, exc_tb = sys.exc_info()
+            synopsis = "'%s', %s" % (exc_name, exc_msg)
+            exc_name = exc_msg = exc_tb = None
+
             # retry guard
-            if self.retries + 1 > self.max_retries:
-                # dont schedule a retry, we've failed
-                msg = ('Task "%s" scheduled for %s failed due to maximum '
-                       'retries exceeded' % (self.description,
-                                                   pretty_time(self.when)))
-                LOG('Scheduler', ERROR, msg)
+            if (self.retries + 1) > self.max_retries:
+                msg = ('Task "%s" scheduled for %s failed on exception'
+                       '- not rescheduling due to exceeded maximum retries.'
+                       '  Exception: %s'
+                       % (self.description, pretty_time(self.when), synopsis))
+                LOG('Scheduler', ERROR, msg, error=sys.exc_info())
                 return 1
             
             then = now + self.retry_backoff_time
 
             # primary max_age guard
             if then > self.when + self.max_age:
-                # dont schedule a retry, we've failed
-                msg = ('Task "%s" scheduled for %s failed due to maximum '
-                       'age exceeded' % (self.description,
-                                               pretty_time(self.when)))
-                LOG('Scheduler', ERROR, msg)
+                msg = ('Task "%s" scheduled for %s failed on exception'
+                       ' - not rescheduling due to exceeded maximum age'
+                       '  Exception: %s'
+                       % (self.description, pretty_time(self.when), synopsis))
+                LOG('Scheduler', ERROR, msg, error=sys.exc_info())
                 return 1
 
             # we schedule a retry if we get to here
-            msg = ('Task "%s" scheduled for %s could not be completed due '
-                   'to an exception, retrying at %s' % (self.description,
-                                                        pretty_time(self.when),
-                                                        pretty_time(then)))
+            msg = ('Task "%s" scheduled for %s was not completed due '
+                   'to an exception - retrying at %s.'
+                   '  Exception: %s.'
+                   % (self.description, pretty_time(self.when),
+                      pretty_time(then), synopsis))
             LOG('Scheduler', PROBLEM, msg, error=sys.exc_info())
             self.retries = self.retries + 1
             return then, self