registry.cleanup() now writes information to job.exc_info (#1226)

main
Selwin Ong 5 years ago committed by GitHub
parent a090e9e840
commit 636d6d2f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -135,6 +135,7 @@ class StartedJobRegistry(BaseRegistry):
job = self.job_class.fetch(job_id, job = self.job_class.fetch(job_id,
connection=self.connection) connection=self.connection)
job.set_status(JobStatus.FAILED) job.set_status(JobStatus.FAILED)
job.exc_info = "Moved to FailedJobRegistry at %s" % datetime.now()
job.save(pipeline=pipeline, include_meta=False) job.save(pipeline=pipeline, include_meta=False)
job.cleanup(ttl=-1, pipeline=pipeline) job.cleanup(ttl=-1, pipeline=pipeline)
failed_job_registry.add(job, job.failure_ttl) failed_job_registry.add(job, job.failure_ttl)

@ -724,7 +724,7 @@ class Worker(object):
self.handle_job_failure( self.handle_job_failure(
job, job,
exc_string="Work-horse process was terminated unexpectedly " exc_string="Work-horse was terminated unexpectedly "
"(waitpid returned %s)" % ret_val "(waitpid returned %s)" % ret_val
) )

@ -152,6 +152,7 @@ class TestRegistry(RQTestCase):
self.assertNotIn(job, self.registry) self.assertNotIn(job, self.registry)
job.refresh() job.refresh()
self.assertEqual(job.get_status(), JobStatus.FAILED) self.assertEqual(job.get_status(), JobStatus.FAILED)
self.assertTrue(job.exc_info) # explanation is written to exc_info
def test_job_execution(self): def test_job_execution(self):
"""Job is removed from StartedJobRegistry after execution.""" """Job is removed from StartedJobRegistry after execution."""

Loading…
Cancel
Save