如何获取 rq 队列中的作业数量?

nic*_*ine 4 python resque

我使用过rq和 RedisToGo。如何获取队列中的作业数量?我在文档中找不到它?(Python)

当我尝试时:

print "Before: ", len(q.jobs)
result = q.enqueue(worker.A)
result = q.enqueue(worker.B)
print "After: ", len(q.jobs)
Run Code Online (Sandbox Code Playgroud)

两次都只给出 0。

Byr*_*uth 5

对于 RQ,您应该能够获取len队列中的作业:

from rq import Queue

queue = Queue()
len(queue)
Run Code Online (Sandbox Code Playgroud)

  • 看起来还有一个“q.count”属性。https://github.com/nvie/rq/blob/master/rq/queue.py#L85-L88 (2认同)