Example #1
0
    def __init__(self, default_timeout=None, connection=None):
        super(FailedQueue, self).__init__(
            name=NotImplemented,
            default_timeout=default_timeout,
            connection=connection,
        )

        self._registries = (q.failed_job_registry for q in Queue.all())
        self._job_ids = None
    def __init__(self, default_timeout=None, connection=None):
        super(FailedQueue, self).__init__(
            name=NotImplemented,
            default_timeout=default_timeout,
            connection=connection,
        )

        self._registries = ((q, q.failed_job_registry) for q in Queue.all())
        self._job_ids = None
    def queues(cls):
        cls.connect()

        def compact_queue(q):
            q.compact()
            return q
        queues = serialize_queues(sorted(map(compact_queue, Queue.all())))
        queues.append(cls.queue('success'))
        return queues
Example #4
0
    def queues(cls):
        cls.connect()

        def compact_queue(q):
            q.compact()
            return q

        queues = serialize_queues(sorted(map(compact_queue, Queue.all())))
        queues.append(cls.queue('success'))
        return queues
def _get_failed_jobs(connection):
    queues = Queue.all(connection=connection)
    failed_jobs = []

    for q in queues:
        registry = FailedJobRegistry(q.name, connection=connection)

        job_ids = registry.get_job_ids()

        for id in job_ids:
            j = rq_job.Job.fetch(id, connection=connection)
            failed_jobs.append(_create_failed_job_obj(j))

    return failed_jobs
Example #6
0
    def test_create_and_requeue_job(self):
        """Requeueing existing jobs."""
        job = Job.create(func=fixtures.div_by_zero, args=(1, 2, 3))
        job.origin = 'fake'
        job.save()
        get_failed_queue().quarantine(job, Exception('Some fake error'))  # noqa

        self.assertEqual(Queue.all(), [get_failed_queue()])  # noqa
        self.assertEqual(get_failed_queue().count, 1)

        requeued_job = requeue_job(job.id)

        self.assertEqual(get_failed_queue().count, 0)
        self.assertEqual(Queue('fake').count, 1)
        self.assertEqual(requeued_job.origin, job.origin)
Example #7
0
    def test_create_and_requeue_job(self):
        """Requeueing existing jobs."""
        job = Job.create(func=fixtures.div_by_zero, args=(1, 2, 3))
        job.origin = 'fake'
        job.save()
        get_failed_queue().quarantine(job, Exception('Some fake error'))  # noqa

        self.assertEqual(Queue.all(), [get_failed_queue()])  # noqa
        self.assertEqual(get_failed_queue().count, 1)

        requeued_job = requeue_job(job.id)

        self.assertEqual(get_failed_queue().count, 0)
        self.assertEqual(Queue('fake').count, 1)
        self.assertEqual(requeued_job.origin, job.origin)
Example #8
0
def queues():
    """Reeport on progress by queues."""
    conn = worker.connection
    failure_q = None

    def _repr(q):
        return "running:%d pending:%d finished:%d" % (StartedJobRegistry(
            q.name, conn).count, q.count, FinishedJobRegistry(q.name,
                                                              conn).count)

    for q in Queue.all(conn):
        if q.name == 'failed':
            failure_q = q
            continue
        click.echo("%s %s" % (q.name, _repr(q)))
    if failure_q:
        click.echo(
            click.style(failure_q.name, fg='red') + ' %s' % _repr(failure_q))
Example #9
0
def queues():
    """Report on progress by queues."""
    conn = worker.connection
    failure_q = None

    def _repr(q):
        return "running:%d pending:%d finished:%d" % (
            StartedJobRegistry(q.name, conn).count,
            q.count,
            FinishedJobRegistry(q.name, conn).count)
    for q in Queue.all(conn):
        if q.name == 'failed':
            failure_q = q
            continue
        click.echo("%s %s" % (q.name, _repr(q)))
    if failure_q:
        click.echo(
            click.style(failure_q.name, fg='red') + ' %s' % _repr(failure_q))
Example #10
0
def list_all_queues():
    """
    :return: Iterable for all available queue instances
    """
    return Queue.all()
Example #11
0
def get_all_queues():
    return Queue.all() + [FailedQueue()]
def _all_queues(rq):
    from rq.queue import Queue
    return Queue.all(connection=rq.connection)
def get_all_queues():
    return Queue.all() + [FailedQueue()]