Parcourir la source

.task.control.discard_all(): Use the ConsumerSet so all custom queues are purged as well. Thanks to Mat Clayton.

Ask Solem il y a 15 ans
Parent
commit
8d70c34e0a
1 fichiers modifiés avec 5 ajouts et 4 suppressions
  1. 5 4
      celery/task/control.py

+ 5 - 4
celery/task/control.py

@@ -1,5 +1,6 @@
 from celery import conf
-from celery.messaging import TaskConsumer, BroadcastPublisher, with_connection
+from celery.messaging import BroadcastPublisher
+from celery.messaging import with_connection, get_consumer_set
 
 
 @with_connection
@@ -13,11 +14,11 @@ def discard_all(connection=None,
     :returns: the number of tasks discarded.
 
     """
-    consumer = TaskConsumer(connection=connection)
+    consumers = get_consumer_set(connection=connection)
     try:
-        return consumer.discard_all()
+        return consumers.discard_all()
     finally:
-        consumer.close()
+        consumers.close()
 
 
 def revoke(task_id, destination=None, connection=None,