Explorar el Código

Fixes worker crash after using --purge

Ask Solem hace 9 años
padre
commit
ded6e062cb
Se han modificado 1 ficheros con 5 adiciones y 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):
     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.'):
     def tasklist(self, include_builtins=True, sep='\n', int_='celery.'):
         return sep.join(
         return sep.join(