本文整理汇总了Python中rq.registry.DeferredJobRegistry.remove方法的典型用法代码示例。如果您正苦于以下问题:Python DeferredJobRegistry.remove方法的具体用法?Python DeferredJobRegistry.remove怎么用?Python DeferredJobRegistry.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rq.registry.DeferredJobRegistry
的用法示例。
在下文中一共展示了DeferredJobRegistry.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enqueue_job
# 需要导入模块: from rq.registry import DeferredJobRegistry [as 别名]
# 或者: from rq.registry.DeferredJobRegistry import remove [as 别名]
def enqueue_job(request, queue_index, job_id):
""" Enqueue deferred jobs
"""
queue_index = int(queue_index)
queue = get_queue_by_index(queue_index)
job = Job.fetch(job_id, connection=queue.connection)
if request.method == 'POST':
queue.enqueue_job(job)
# Remove job from correct registry if needed
if job.get_status() == JobStatus.DEFERRED:
registry = DeferredJobRegistry(queue.name, queue.connection)
registry.remove(job)
elif job.get_status() == JobStatus.FINISHED:
registry = FinishedJobRegistry(queue.name, queue.connection)
registry.remove(job)
messages.info(request, 'You have successfully enqueued %s' % job.id)
return redirect('rq_job_detail', queue_index, job_id)
context_data = {
'queue_index': queue_index,
'job': job,
'queue': queue,
}
return render(request, 'django_rq/delete_job.html', context_data)