Change `rq requeue` subtly, mostly docs and vars.

main
Vincent Driessen 10 years ago
parent 07dda74710
commit 5c96c61255

@ -5,6 +5,8 @@ RQ command line tool
from __future__ import (absolute_import, division, print_function, from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
import sys
import click import click
import redis import redis
from rq import get_failed_queue, Queue from rq import get_failed_queue, Queue
@ -47,40 +49,32 @@ def empty(ctx, all, queues):
@main.command() @main.command()
@click.option('--all', '-a', 'is_all', is_flag=True, help='Requeue all failed jobs') @click.option('--all', '-a', is_flag=True, help='Requeue all failed jobs')
@click.argument('job_ids', nargs=-1) @click.argument('job_ids', nargs=-1)
@click.pass_context @click.pass_context
def requeue(ctx, is_all, job_ids): def requeue(ctx, all, job_ids):
"""[JOB_IDS] Job_ids in FailedQueue to requeue """Requeue failed jobs."""
\b
$ rq requeue -a
Requeueing 10 jobs from FailedQueue
[####################################] 100%
Unable to requeue 0 jobs from FailedQueue
\b
$ rq requeue a28bd044-65f3-42dd-96ee-acfcea155ba7\
ac5559e1-90a0-4ab5-8e68-0d854b47b969
Requeueing 2 jobs from FailedQueue
[####################################] 100%
Unable to requeue 1 jobs from FailedQueue
"""
conn = ctx.obj['connection'] conn = ctx.obj['connection']
failed_queue = get_failed_queue(connection=conn) failed_queue = get_failed_queue(connection=conn)
if not job_ids and is_all:
if all:
job_ids = failed_queue.job_ids job_ids = failed_queue.job_ids
click.echo('Requeueing {0} jobs from FailedQueue'.format(len(job_ids)))
requeue_failed_num = 0 if not job_ids:
with click.progressbar(job_ids) as job_bar: click.echo('Nothing to do')
for job_id in job_bar: sys.exit(0)
click.echo('Requeueing {0} jobs from failed queue'.format(len(job_ids)))
fail_count = 0
with click.progressbar(job_ids) as job_ids:
for job_id in job_ids:
try: try:
failed_queue.requeue(job_id) failed_queue.requeue(job_id)
except InvalidJobOperationError: except InvalidJobOperationError:
requeue_failed_num += 1 fail_count += 1
click.secho('Unable to requeue {0} jobs from FailedQueue'.format( if fail_count > 0:
requeue_failed_num), fg='red') click.secho('Unable to requeue {0} jobs from failed queue'.format(fail_count), fg='red')
main.add_command(info) main.add_command(info)

Loading…
Cancel
Save