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

Question:

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.

Asked By: nickponline

||

Answers:

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)
Answered By: Byron Ruth
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.