Prefer `result` over `return_value`.

`return_value` still is available as a backward-compatible accessor.

This fixes #116.
main
Vincent Driessen 13 years ago
parent 978ba2dff9
commit 83369f3b9b

@ -172,7 +172,7 @@ class Job(object):
return (self.func_name, self.instance, self.args, self.kwargs)
@property
def return_value(self):
def result(self):
"""Returns the return value of the job.
Initially, right after enqueueing a job, the return value will be
@ -195,6 +195,9 @@ class Job(object):
self._result = loads(rv)
return self._result
"""Backwards-compatibility accessor property `return_value`."""
return_value = self.result
# Persistence
def refresh(self): # noqa

@ -25,7 +25,7 @@ class TestJob(RQTestCase):
self.assertIsNone(job.origin)
self.assertIsNone(job.enqueued_at)
self.assertIsNone(job.ended_at)
self.assertIsNone(job.return_value)
self.assertIsNone(job.result)
self.assertIsNone(job.exc_info)
def test_create_typical_job(self):
@ -46,7 +46,7 @@ class TestJob(RQTestCase):
# ...but metadata is not
self.assertIsNone(job.origin)
self.assertIsNone(job.enqueued_at)
self.assertIsNone(job.return_value)
self.assertIsNone(job.result)
def test_create_instance_method_job(self):
"""Creation of jobs for instance methods."""

@ -29,10 +29,10 @@ class TestWorker(RQTestCase):
"""Worker processes work fed via string arguments."""
q = Queue('foo')
w = Worker([q])
result = q.enqueue('tests.fixtures.say_hello', name='Frank')
job = q.enqueue('tests.fixtures.say_hello', name='Frank')
self.assertEquals(w.work(burst=True), True,
'Expected at least some work done.')
self.assertEquals(result.return_value, 'Hi there, Frank!')
self.assertEquals(job.result, 'Hi there, Frank!')
def test_work_is_unreadable(self):
"""Unreadable jobs are put on the failed queue."""
@ -109,11 +109,11 @@ class TestWorker(RQTestCase):
raise
q = Queue()
result = q.enqueue(create_file, SENTINEL_FILE)
job = q.enqueue(create_file, SENTINEL_FILE)
# Here, we cancel the job, so the sentinel file may not be created
assert q.count == 1
result.cancel()
job.cancel()
assert q.count == 1
w = Worker([q])

Loading…
Cancel
Save