Add '--all' option and [JOB_IDS] argument to specify what to requeue

main
zhangliyong 10 years ago
parent 37748e5ace
commit 5670f251d8

@ -61,13 +61,31 @@ def empty(ctx, yes, queues):
@main.command()
@click.option('--all', '-a', 'is_all', is_flag=True,
help='Requeue all failed jobs')
@click.argument('job_ids', nargs=-1)
@click.pass_context
def requeue(ctx):
"""Requeue all failed jobs in failed queue"""
def requeue(ctx, is_all, job_ids):
"""[JOB_IDS] Job_ids in FailedQueue to requeue
\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']
failed_queue = get_failed_queue(connection=conn)
if not job_ids and is_all:
job_ids = failed_queue.job_ids
click.echo('Requeue failed jobs: {0}'.format(len(job_ids)))
click.echo('Requeueing {0} jobs from FailedQueue'.format(len(job_ids)))
requeue_failed_num = 0
with click.progressbar(job_ids) as job_bar:
for job_id in job_bar:
@ -76,7 +94,7 @@ def requeue(ctx):
except InvalidJobOperationError:
requeue_failed_num += 1
click.secho('Requeue failed: {0}'.format(
click.secho('Unable to requeue {0} jobs from FailedQueue'.format(
requeue_failed_num), fg='red')

Loading…
Cancel
Save