@@ -97,7 +97,7 @@ def mark_lost_jobs(self):
97
97
# In theory we could save a timeout per-job and mark them timed-out more quickly,
98
98
# but if they're still running, we can't actually send a signal to cancel it...
99
99
now = timezone .now ()
100
- cutoff = now - datetime .timedelta (seconds = settings .JOBS_LOST_AFTER )
100
+ cutoff = now - datetime .timedelta (seconds = settings .WORKER_JOBS_LOST_AFTER )
101
101
lost_jobs = self .filter (
102
102
created_at__lt = cutoff
103
103
) # Doesn't matter whether it started or not -- it shouldn't take this long.
@@ -183,6 +183,22 @@ def convert_to_result(self, *, status, error=""):
183
183
184
184
return result
185
185
186
+ def as_json (self ):
187
+ """A JSON-compatible representation to make it easier to reference in Sentry or logging"""
188
+ return {
189
+ "uuid" : str (self .uuid ),
190
+ "created_at" : self .created_at .isoformat (),
191
+ "started_at" : self .started_at .isoformat () if self .started_at else None ,
192
+ "job_request_uuid" : str (self .job_request_uuid ),
193
+ "job_class" : self .job_class ,
194
+ "parameters" : self .parameters ,
195
+ "priority" : self .priority ,
196
+ "source" : self .source ,
197
+ "retries" : self .retries ,
198
+ "retry_attempt" : self .retry_attempt ,
199
+ "unique_key" : self .unique_key ,
200
+ }
201
+
186
202
187
203
class JobResultQuerySet (models .QuerySet ):
188
204
def successful (self ):
0 commit comments