@@ -97,7 +97,7 @@ def mark_lost_jobs(self):
9797 # In theory we could save a timeout per-job and mark them timed-out more quickly,
9898 # but if they're still running, we can't actually send a signal to cancel it...
9999 now = timezone .now ()
100- cutoff = now - datetime .timedelta (seconds = settings .JOBS_LOST_AFTER )
100+ cutoff = now - datetime .timedelta (seconds = settings .WORKER_JOBS_LOST_AFTER )
101101 lost_jobs = self .filter (
102102 created_at__lt = cutoff
103103 ) # 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=""):
183183
184184 return result
185185
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+
186202
187203class JobResultQuerySet (models .QuerySet ):
188204 def successful (self ):
0 commit comments