Преглед на файлове

Fixes worker crash after using --purge

Ask Solem преди 9 години
родител
ревизия
ded6e062cb
променени са 1 файла, в които са добавени 5 реда и са изтрити 4 реда
  1. 5 4
      celery/apps/worker.py

+ 5 - 4
celery/apps/worker.py

@@ -162,10 +162,11 @@ class Worker(WorkController):
         )
 
     def purge_messages(self):
-        count = self.app.control.purge()
-        if count:  # pragma: no cover
-            print('purge: Erased {0} {1} from the queue.\n'.format(
-                count, pluralize(count, 'message')))
+        with self.app.connection_for_write() as connection:
+            count = self.app.control.purge(connection=connection)
+            if count:  # pragma: no cover
+                print('purge: Erased {0} {1} from the queue.\n'.format(
+                    count, pluralize(count, 'message')))
 
     def tasklist(self, include_builtins=True, sep='\n', int_='celery.'):
         return sep.join(