From 5f6a1f0ac55be40bc6e14ca68776c5434ef29b65 Mon Sep 17 00:00:00 2001 From: Mark Tozzi Date: Thu, 5 Sep 2013 12:05:42 -0400 Subject: [PATCH] Empty the queue before deleteing the jobs, in case new jobs arrive --- rq/queue.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index fc1ea08..dcbeeba 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -65,9 +65,10 @@ class Queue(object): def empty(self): """Removes all messages on the queue.""" - for job in self.get_jobs(): - job.cancel() + job_list = self.get_jobs() self.connection.delete(self.key) + for job in job_list: + job.cancel() def is_empty(self): """Returns whether the current queue is empty."""