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

This fixes #36.
main
Vincent Driessen 13 years ago
parent 98ea29b15a
commit c684949045

@ -1,6 +1,6 @@
from redis import Redis
from .proxy import conn
from .queue import Queue, FailedQueue
from .queue import Queue, get_failed_queue
from .job import cancel_job, requeue_job
from .worker import Worker
from .version import VERSION
@ -22,6 +22,6 @@ def use_redis(redis=None):
__all__ = [
'conn', 'use_redis',
'Queue', 'FailedQueue', 'Worker',
'Queue', 'get_failed_queue', 'Worker',
'cancel_job', 'requeue_job']
__version__ = VERSION

@ -5,6 +5,11 @@ from .job import Job
from .exceptions import NoSuchJobError, UnpickleError, InvalidJobOperationError
def get_failed_queue():
"""Returns a handle to the special failed queue."""
return FailedQueue()
def compact(lst):
return [item for item in lst if item is not None]

@ -1,6 +1,6 @@
from tests import RQTestCase
from tests.fixtures import say_hello, div_by_zero
from rq import Queue, FailedQueue
from rq import Queue, get_failed_queue
from rq.job import Job
from rq.exceptions import InvalidJobOperationError
@ -199,14 +199,14 @@ class TestFailedQueue(RQTestCase):
job = Job.create(div_by_zero, 1, 2, 3)
job.origin = 'fake'
job.save()
FailedQueue().quarantine(job, Exception('Some fake error'))
get_failed_queue().quarantine(job, Exception('Some fake error'))
self.assertItemsEqual(Queue.all(), [FailedQueue()])
self.assertEquals(FailedQueue().count, 1)
self.assertItemsEqual(Queue.all(), [get_failed_queue()])
self.assertEquals(get_failed_queue().count, 1)
FailedQueue().requeue(job.id)
get_failed_queue().requeue(job.id)
self.assertEquals(FailedQueue().count, 0)
self.assertEquals(get_failed_queue().count, 0)
self.assertEquals(Queue('fake').count, 1)
def test_requeue_nonfailed_job_fails(self):
@ -216,4 +216,4 @@ class TestFailedQueue(RQTestCase):
# Assert that we cannot requeue a job that's not on the failed queue
with self.assertRaises(InvalidJobOperationError):
FailedQueue().requeue(job.id)
get_failed_queue().requeue(job.id)

Loading…
Cancel
Save