From fd44ad39d49e1ea978384d1480653781fa75175c Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Tue, 3 Sep 2013 08:03:50 +0700 Subject: [PATCH] Python 3 fixes for job dependency stuff. --- rq/job.py | 2 +- rq/queue.py | 2 +- tests/test_job.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rq/job.py b/rq/job.py index 7eaf532..a10c340 100644 --- a/rq/job.py +++ b/rq/job.py @@ -318,7 +318,7 @@ class Job(object): self.timeout = int(obj.get('timeout')) if obj.get('timeout') else None self.result_ttl = int(obj.get('result_ttl')) if obj.get('result_ttl') else None # noqa self._status = as_text(obj.get('status') if obj.get('status') else None) - self._dependency_id = obj.get('dependency_id', None) + self._dependency_id = as_text(obj.get('dependency_id', None)) self.meta = unpickle(obj.get('meta')) if obj.get('meta') else {} def dump(self): diff --git a/rq/queue.py b/rq/queue.py index 79442ac..e9f3c7f 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -240,7 +240,7 @@ class Queue(object): """Enqueues all jobs in the waitlist and clears it""" # TODO: can probably be pipelined while True: - job_id = self.connection.lpop(job.waitlist_key) + job_id = as_text(self.connection.lpop(job.waitlist_key)) if job_id is None: break waitlisted_job = Job.fetch(job_id, connection=self.connection) diff --git a/tests/test_job.py b/tests/test_job.py index 13ef368..bc70d5e 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -7,6 +7,7 @@ try: from cPickle import loads except ImportError: from pickle import loads +from rq.compat import as_text from rq.job import Job, get_current_job from rq.exceptions import NoSuchJobError, UnpickleError from rq.queue import Queue @@ -288,4 +289,4 @@ class TestJob(RQTestCase): job._dependency_id = 'id' job.save() job.register_dependency() - self.assertEqual(self.testconn.lpop('rq:job:id:waitlist'), job.id) + self.assertEqual(as_text(self.testconn.lpop('rq:job:id:waitlist')), job.id)