2

Given:

from redis import Redis
from rq import Queue

yesterday = Queue('yesterday', connection=Redis())
today = Queue('today', connection=Redis())

I would like to programmatically delete the Queue named 'yesterday'

1 Answer 1

4

Try the following (you can validate all of this with redis-cli):

yesterday.empty()  # This will wipe out rq:queue:yesterday and all of its contents
del(yesterday)  # Deletes the variable itself
r = Redis()
r.srem('rq:queues', 'rq:queue:yesterday')  # Removed the entry from rq:queues set. The library unfortunately doesn't seem to clean this up by itself.
Sign up to request clarification or add additional context in comments.

3 Comments

Is there a way to do this within the rq library?
@CarlSagan, I poked around quickly in the rq library's public interface. I didn't find anything useful. You may want to just make a rq Queue wrapper that does all this cleanup inside __del__
The paramter ttl in q.enqueue_call could be used to clear queues of jobs. If it worked, that is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.