如何获取 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)