Store how many times a job has timed out and abort if needed
Patch by: Sverre Rabblier
--- a/app/soc/cron/job.py Sat Apr 18 21:34:41 2009 +0000
+++ b/app/soc/cron/job.py Sun Apr 19 00:06:12 2009 +0000
@@ -88,6 +88,24 @@
return job.put()
+ def timeoutJob(self, job_key):
+ """A transaction to tiemout a job.
+ """
+
+ job = Job.get_by_id(job_key)
+
+ job.timeouts += 1
+
+ if job.timeouts > 50:
+ job.status = 'aborted'
+ else:
+ job.status = 'waiting'
+
+ job_id = job.key().id()
+ logging.debug("job %d now timeout %d time(s)" % (job_id, job.timeouts))
+
+ return job.put()
+
def failJob(self, job_key):
"""A transaction to fail a job.
"""
@@ -150,7 +168,7 @@
db.run_in_transaction(self.finishJob, job_key)
return True
except DeadlineExceededError, exception:
- db.run_in_transaction(self.freeJob, job_key)
+ db.run_in_transaction(self.timeoutJob, job_key)
return False
except FatalJobError, exception:
logging.exception(exception)
--- a/app/soc/models/job.py Sat Apr 18 21:34:41 2009 +0000
+++ b/app/soc/models/job.py Sun Apr 19 00:06:12 2009 +0000
@@ -52,9 +52,12 @@
last_modified_on = db.DateTimeProperty(auto_now_add=True)
#: the amount of times this job raised an Exception (other than a
- #: DeadlineExceededException).
+ #: DeadlineExceededError).
errors = db.IntegerProperty(default=0)
+ #: the amount of times this job raised an DeadlineExceededError.
+ timeouts = db.IntegerProperty(default=0)
+
#: the data that the worker will use to process this job
text_data = db.TextProperty(required=False, default="")