Don't expose the Job class at the top-level.

This partially fixes #37.
main
Vincent Driessen 13 years ago
parent 0b837b4b12
commit 98ea29b15a

@ -1,8 +1,8 @@
from redis import Redis from redis import Redis
from .proxy import conn from .proxy import conn
from .queue import Queue, FailedQueue from .queue import Queue, FailedQueue
from .job import cancel_job, requeue_job
from .worker import Worker from .worker import Worker
from .job import Job
from .version import VERSION from .version import VERSION
@ -20,5 +20,8 @@ def use_redis(redis=None):
raise TypeError('Argument redis should be a Redis instance.') raise TypeError('Argument redis should be a Redis instance.')
conn.push(redis) conn.push(redis)
__all__ = ['conn', 'Queue', 'FailedQueue', 'Worker', 'Job', 'use_redis'] __all__ = [
'conn', 'use_redis',
'Queue', 'FailedQueue', 'Worker',
'cancel_job', 'requeue_job']
__version__ = VERSION __version__ = VERSION

@ -21,6 +21,21 @@ def unpickle(pickled_string):
return obj return obj
def cancel_job(job_id):
"""Cancels the job with the given job ID, preventing execution. Discards
any job info (i.e. it can't be requeued later).
"""
Job(job_id).cancel()
def requeue_job(job_id):
"""Requeues the job with the given job ID. The job ID should refer to
a failed job (i.e. it should be on the failed queue). If no such (failed)
job exists, a NoSuchJobError is raised.
"""
raise NotImplementedError('Go implement this')
class Job(object): class Job(object):
"""A Job is just a convenient datastructure to pass around job (meta) data. """A Job is just a convenient datastructure to pass around job (meta) data.
""" """

@ -4,7 +4,7 @@ from tests import RQTestCase
from tests.fixtures import some_calculation, say_hello from tests.fixtures import some_calculation, say_hello
from tests.helpers import strip_milliseconds from tests.helpers import strip_milliseconds
from cPickle import loads from cPickle import loads
from rq import Job from rq.job import Job
from rq.exceptions import NoSuchJobError, UnpickleError from rq.exceptions import NoSuchJobError, UnpickleError

@ -1,6 +1,7 @@
from tests import RQTestCase from tests import RQTestCase
from tests.fixtures import say_hello, div_by_zero from tests.fixtures import say_hello, div_by_zero
from rq import Queue, FailedQueue, Job from rq import Queue, FailedQueue
from rq.job import Job
from rq.exceptions import InvalidJobOperationError from rq.exceptions import InvalidJobOperationError

@ -3,7 +3,8 @@ from tests import RQTestCase, slow
from tests.fixtures import say_hello, div_by_zero, do_nothing, create_file, \ from tests.fixtures import say_hello, div_by_zero, do_nothing, create_file, \
create_file_after_timeout create_file_after_timeout
from tests.helpers import strip_milliseconds from tests.helpers import strip_milliseconds
from rq import Queue, Worker, Job from rq import Queue, Worker
from rq.job import Job
class TestWorker(RQTestCase): class TestWorker(RQTestCase):

Loading…
Cancel
Save