equal
deleted
inserted
replaced
26 |
26 |
27 from google.appengine.ext import db |
27 from google.appengine.ext import db |
28 from google.appengine.runtime import DeadlineExceededError |
28 from google.appengine.runtime import DeadlineExceededError |
29 |
29 |
30 from soc.models.job import Job |
30 from soc.models.job import Job |
|
31 |
|
32 |
|
33 class Error(Exception): |
|
34 """Base class for all exceptions raised by this module. |
|
35 """ |
|
36 pass |
|
37 |
|
38 |
|
39 class FatalJobError(Error): |
|
40 """Class for all errors that lead to immediate job abortion. |
|
41 """ |
|
42 pass |
31 |
43 |
32 |
44 |
33 class Handler(object): |
45 class Handler(object): |
34 """A handler that dispatches a cron job. |
46 """A handler that dispatches a cron job. |
35 |
47 |
134 db.run_in_transaction(self.finishJob, job_key) |
146 db.run_in_transaction(self.finishJob, job_key) |
135 return True |
147 return True |
136 except DeadlineExceededError, exception: |
148 except DeadlineExceededError, exception: |
137 db.run_in_transaction(self.freeJob, job_key) |
149 db.run_in_transaction(self.freeJob, job_key) |
138 return False |
150 return False |
|
151 except FatalJobError, exception: |
|
152 logging.exception(exception) |
|
153 db.run_in_transaction(self.abortJob, job_key) |
|
154 return True |
139 except Exception, exception: |
155 except Exception, exception: |
140 logging.exception(exception) |
156 logging.exception(exception) |
141 db.run_in_transaction(self.failJob, job_key) |
157 db.run_in_transaction(self.failJob, job_key) |
142 return True |
158 return True |
143 |
159 |