Added FatalJobError to the cron/job module.
authorLennard de Rijk <ljvderijk@gmail.com>
Sat, 18 Apr 2009 15:04:24 +0000
changeset 2217 2c6ec0357149
parent 2216 2ac430aa5799
child 2218 84b0ce492cf5
Added FatalJobError to the cron/job module. This Error will lead to abortion of the raising job. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/cron/job.py
--- 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)