Python 3 fixes for job dependency stuff.

main
Selwin Ong 11 years ago
parent fcfe55fe13
commit fd44ad39d4

@ -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):

@ -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)

@ -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)

Loading…
Cancel
Save