Merge branch 'master' into custom-queue-class

Conflicts:
	tests/test_worker.py
main
Antoine Leclair 9 years ago
commit 81679a35d9

@ -598,7 +598,7 @@ class Worker(object):
result_ttl = job.get_result_ttl(self.default_result_ttl) result_ttl = job.get_result_ttl(self.default_result_ttl)
if result_ttl != 0: if result_ttl != 0:
job.ended_at = utcnow() job.ended_at = utcnow()
job._status = JobStatus.FINISHED job.set_status(JobStatus.FINISHED, pipeline=pipeline)
job.save(pipeline=pipeline) job.save(pipeline=pipeline)
finished_job_registry = FinishedJobRegistry(job.origin, self.connection) finished_job_registry = FinishedJobRegistry(job.origin, self.connection)

@ -412,7 +412,7 @@ class TestQueue(RQTestCase):
self.assertEqual(job.get_status(), JobStatus.QUEUED) self.assertEqual(job.get_status(), JobStatus.QUEUED)
def test_enqueue_job_with_dependency_by_id(self): def test_enqueue_job_with_dependency_by_id(self):
""""Can specify job dependency with job object or job id.""" """Can specify job dependency with job object or job id."""
parent_job = Job.create(func=say_hello) parent_job = Job.create(func=say_hello)
q = Queue() q = Queue()

@ -116,9 +116,9 @@ class TestWorker(RQTestCase):
self.assertIsNotNone(job.enqueued_at) self.assertIsNotNone(job.enqueued_at)
self.assertIsNone(job.started_at) self.assertIsNone(job.started_at)
self.assertIsNone(job.ended_at) self.assertIsNone(job.ended_at)
self.assertEquals(w.work(burst=True), True, self.assertEqual(w.work(burst=True), True,
'Expected at least some work done.') 'Expected at least some work done.')
self.assertEquals(job.result, 'Hi there, Stranger!') self.assertEqual(job.result, 'Hi there, Stranger!')
after = utcnow() after = utcnow()
job.refresh() job.refresh()
self.assertTrue(before <= job.enqueued_at <= after, 'Not %s <= %s <= %s' % (before, job.enqueued_at, after)) self.assertTrue(before <= job.enqueued_at <= after, 'Not %s <= %s <= %s' % (before, job.enqueued_at, after))
@ -177,7 +177,7 @@ class TestWorker(RQTestCase):
# Postconditions # Postconditions
self.assertEqual(q.count, 0) self.assertEqual(q.count, 0)
self.assertEqual(failed_q.count, 1) self.assertEqual(failed_q.count, 1)
self.assertEquals(w.get_current_job_id(), None) self.assertEqual(w.get_current_job_id(), None)
# Check the job # Check the job
job = Job.fetch(job.id) job = Job.fetch(job.id)
@ -367,6 +367,16 @@ class TestWorker(RQTestCase):
self.assertEqual(worker_generic.queue_class, Queue) self.assertEqual(worker_generic.queue_class, Queue)
self.assertEqual(Worker.queue_class, Queue) self.assertEqual(Worker.queue_class, Queue)
def test_custom_job_class_is_not_global(self):
"""Ensure Worker custom job class is not global."""
q = Queue()
worker_custom = Worker([q], job_class=CustomJob)
q_generic = Queue()
worker_generic = Worker([q_generic])
self.assertEqual(worker_custom.job_class, CustomJob)
self.assertEqual(worker_generic.job_class, Job)
self.assertEqual(Worker.job_class, Job)
def test_work_via_simpleworker(self): def test_work_via_simpleworker(self):
"""Worker processes work, with forking disabled, """Worker processes work, with forking disabled,
then returns.""" then returns."""

Loading…
Cancel
Save