app/soc/cron/job.py
changeset 2217 2c6ec0357149
parent 2213 c0f52da7a808
child 2219 6f835882160e
--- a/app/soc/cron/job.py	Sat Apr 18 14:51:27 2009 +0000
+++ b/app/soc/cron/job.py	Sat Apr 18 15:04:24 2009 +0000
@@ -30,6 +30,18 @@
 from soc.models.job import Job
 
 
+class Error(Exception):
+  """Base class for all exceptions raised by this module.
+  """
+  pass
+
+
+class FatalJobError(Error):
+  """Class for all errors that lead to immediate job abortion.
+  """
+  pass
+
+
 class Handler(object):
   """A handler that dispatches a cron job.
 
@@ -136,6 +148,10 @@
     except DeadlineExceededError, exception:
       db.run_in_transaction(self.freeJob, job_key)
       return False
+    except FatalJobError, exception:
+      logging.exception(exception)
+      db.run_in_transaction(self.abortJob, job_key)
+      return True
     except Exception, exception:
       logging.exception(exception)
       db.run_in_transaction(self.failJob, job_key)