Ask Solem 11 роки тому
батько
коміт
09b834253f

+ 13 - 7
celery/bootsteps.py

@@ -143,21 +143,21 @@ class Blueprint(object):
 
     def send_all(self, parent, method,
                  description=None, reverse=True, propagate=True, args=()):
-        description = description or method.capitalize()
+        description = description or method.replace('_', ' ')
         steps = reversed(parent.steps) if reverse else parent.steps
         for step in steps:
             if step:
-                self._debug('%s %s...',
-                            description.capitalize(), step.alias)
                 fun = getattr(step, method, None)
-                if fun:
+                if fun is not None:
+                    self._debug('%s %s...',
+                                description.capitalize(), step.alias)
                     try:
                         fun(parent, *args)
                     except Exception as exc:
                         if propagate:
                             raise
                         logger.error(
-                            'Error while %s %s: %r',
+                            'Error on %s %s: %r',
                             description, step.alias, exc, exc_info=1,
                         )
 
@@ -405,11 +405,17 @@ class ConsumerStep(StartStopStep):
             consumer.consume()
 
     def stop(self, c):
+        self._close(c, True)
+
+    def shutdown(self, c):
+        self._close(c, False)
+
+    def _close(self, c, cancel_consumers=True):
         channels = set()
         for consumer in self.consumers or []:
-            ignore_errors(c.connection, consumer.cancel)
+            if cancel_consumers:
+                ignore_errors(c.connection, consumer.cancel)
             if consumer.channel:
                 channels.add(consumer.channel)
         for channel in channels:
             ignore_errors(c.connection, channel.close)
-    shutdown = stop

+ 1 - 0
celery/fixups/django.py

@@ -19,6 +19,7 @@ Environment variable DJANGO_SETTINGS_MODULE is defined
 but Django is not installed.  Will not apply Django fixups!
 """
 
+
 def _maybe_close_fd(fh):
     try:
         os.close(fh.fileno())

+ 4 - 1
celery/worker/__init__.py

@@ -219,7 +219,10 @@ class WorkController(object):
             self.stop()
 
     def register_with_event_loop(self, hub):
-        self.blueprint.send_all(self, 'register_with_event_loop', args=(hub, ))
+        self.blueprint.send_all(
+            self, 'register_with_event_loop', args=(hub, ),
+            description='hub.register',
+        )
 
     def _process_task_sem(self, req):
         return self._quick_acquire(self._process_task, req)

+ 4 - 1
celery/worker/consumer.py

@@ -287,7 +287,10 @@ class Consumer(object):
                     blueprint.restart(self)
 
     def register_with_event_loop(self, hub):
-        self.blueprint.send_all(self, 'register_with_event_loop', args=(hub, ))
+        self.blueprint.send_all(
+            self, 'register_with_event_loop', args=(hub, ),
+            description='Hub.register',
+        )
 
     def shutdown(self):
         self.in_shutdown = True