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'

Carl Sagan
  • 982
  • 1
  • 13
  • 34

1 Answers1

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.
peakxu
  • 6,667
  • 1
  • 28
  • 27
  • Is there a way to do this within the rq library? – Carl Sagan Aug 05 '14 at 01:58
  • @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__` – peakxu Aug 05 '14 at 10:05
  • The paramter `ttl` in `q.enqueue_call` could be used to clear queues of jobs. If it worked, that is. – atripes Sep 06 '17 at 09:57