如何获取 rq 队列中的作业数量? [英] How do I get the number of jobs in a rq queue?
本文介绍了如何获取 rq 队列中的作业数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了 rq 和 RedisToGo.如何获取队列中的作业数量?我在文档中找不到它?(在 Python 中)
I've using rq and RedisToGo. How do I get the number of jobs in the queue? I can't find it in the documentation? (In Python)
当我尝试时:
print "Before: ", len(q.jobs)
result = q.enqueue(worker.A)
result = q.enqueue(worker.B)
print "After: ", len(q.jobs)
两次都只给出 0.
推荐答案
对于 RQ,您应该能够获得队列中作业的 len
:
For RQ, you should be able to just get the len
of the jobs in a queue:
from rq import Queue
queue = Queue()
len(queue.jobs)
这篇关于如何获取 rq 队列中的作业数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文