Explorar o código

Allow directing a control command to a single host only, by adding a "destination" field contaning the workers hostname.

Ask Solem %!s(int64=15) %!d(string=hai) anos
pai
achega
a2e0491710
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      celery/worker/listener.py

+ 4 - 1
celery/worker/listener.py

@@ -55,6 +55,7 @@ class CarrotListener(object):
         self.event_dispatcher = None
         self.heart = None
         self._state = None
+        self.hostname = socket.gethostname()
 
     def start(self):
         """Start the consumer.
@@ -93,7 +94,9 @@ class CarrotListener(object):
 
     def on_control_command(self, message):
         command = message.pop("command")
-        return self.control_dispatch.dispatch(command, message)
+        destination = message.pop("destination", None)
+        if not destination or destination == self.hostname:
+            return self.control_dispatch.dispatch(command, message)
 
     def on_task(self, task, eta=None):
         """Handle received task.