Explorar o código

Fixes worker crash after using --purge

Ask Solem %!s(int64=9) %!d(string=hai) anos
pai
achega
ded6e062cb
Modificáronse 1 ficheiros con 5 adicións e 4 borrados
  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(