How do I get the number of jobs in a rq queue?

被刻印的时光 ゝ 提交于 2019-12-23 23:41:17

问题


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)

When I try:

print "Before: ", len(q.jobs)
result = q.enqueue(worker.A)
result = q.enqueue(worker.B)
print "After: ", len(q.jobs)

It just gives 0 both times.


回答1:


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)


来源:https://stackoverflow.com/questions/14449296/how-do-i-get-the-number-of-jobs-in-a-rq-queue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!