Selaa lähdekoodia

Worker: Only start pidbox if transport supports fanout. Closes celery/kombu#387

Ask Solem 9 vuotta sitten
vanhempi
commit
2f58c35340
2 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 2 1
      celery/worker/__init__.py
  2. 5 4
      celery/worker/consumer.py

+ 2 - 1
celery/worker/__init__.py

@@ -245,7 +245,8 @@ class WorkController(object):
 
     def should_use_eventloop(self):
         return (detect_environment() == 'default' and
-                self._conninfo.is_evented and not self.app.IS_WINDOWS)
+                self._conninfo.transport.implements.async and
+                not self.app.IS_WINDOWS)
 
     def stop(self, in_sighandler=False, exitcode=None):
         """Graceful shutdown of the worker server."""

+ 5 - 4
celery/worker/consumer.py

@@ -176,9 +176,9 @@ class Consumer(object):
         self.pool = pool
         self.timer = timer
         self.strategies = self.Strategies()
-        conninfo = self.app.connection()
-        self.connection_errors = conninfo.connection_errors
-        self.channel_errors = conninfo.channel_errors
+        self.conninfo = self.app.connection()
+        self.connection_errors = self.conninfo.connection_errors
+        self.channel_errors = self.conninfo.channel_errors
         self._restart_state = restart_state(maxR=5, maxT=1)
 
         self._does_info = logger.isEnabledFor(logging.INFO)
@@ -685,7 +685,8 @@ class Control(bootsteps.StartStopStep):
         self.shutdown = self.box.shutdown
 
     def include_if(self, c):
-        return c.app.conf.CELERY_ENABLE_REMOTE_CONTROL
+        return (c.app.conf.CELERY_ENABLE_REMOTE_CONTROL and
+                'fanout' in c.conninfo.transport.implements.exchange_type)
 
 
 class Gossip(bootsteps.ConsumerStep):