Browse Source

Worker: Adds options --without-mingle --without-gossip --without-heartbeat

Ask Solem 11 years ago
parent
commit
3e1e42e895
3 changed files with 24 additions and 9 deletions
  1. 15 0
      celery/bin/worker.py
  2. 3 3
      celery/tests/worker/test_worker.py
  3. 6 6
      celery/worker/consumer.py

+ 15 - 0
celery/bin/worker.py

@@ -70,6 +70,18 @@ The :program:`celery worker` command (previously known as ``celeryd``)
     Send events that can be captured by monitors like :program:`celery events`,
     `celerymon`, and others.
 
+.. cmdoption:: --without-gossip
+
+    Do not subscribe to other workers events.
+
+.. cmdoption:: --without-mingle
+
+    Do not synchronize with other workers at startup.
+
+.. cmdoption:: --without-heartbeat
+
+    Do not send event heartbeats.
+
 .. cmdoption:: --purge
 
     Purges all waiting tasks before the daemon is started.
@@ -219,6 +231,9 @@ class worker(Command):
             Option('--autoscale'),
             Option('--autoreload', action='store_true'),
             Option('--no-execv', action='store_true', default=False),
+            Option('--without-gossip', action='store_true', default=False),
+            Option('--without-mingle', action='store_true', default=False),
+            Option('--without-heartbeat', action='store_true', default=False),
             Option('-D', '--detach', action='store_true'),
         ) + daemon_options() + tuple(self.app.user_options['worker'])
 

+ 3 - 3
celery/tests/worker/test_worker.py

@@ -50,9 +50,9 @@ def find_step(obj, typ):
 class Consumer(__Consumer):
 
     def __init__(self, *args, **kwargs):
-        kwargs.setdefault('enable_mingle', False)  # disable Mingle step
-        kwargs.setdefault('enable_gossip', False)  # disable Gossip step
-        kwargs.setdefault('enable_heartbeat', False)  # disable Heart step
+        kwargs.setdefault('without_mingle', True)  # disable Mingle step
+        kwargs.setdefault('without_gossip', True)  # disable Gossip step
+        kwargs.setdefault('without_heartbeat', True)  # disable Heart step
         super(Consumer, self).__init__(*args, **kwargs)
 
 

+ 6 - 6
celery/worker/consumer.py

@@ -518,8 +518,8 @@ class Events(bootsteps.StartStopStep):
 class Heart(bootsteps.StartStopStep):
     requires = (Events, )
 
-    def __init__(self, c, enable_heartbeat=True, **kwargs):
-        self.enabled = enable_heartbeat
+    def __init__(self, c, without_heartbeat=False, **kwargs):
+        self.enabled = not without_heartbeat
         c.heart = None
 
     def start(self, c):
@@ -594,8 +594,8 @@ class Gossip(bootsteps.ConsumerStep):
         'id', 'clock', 'hostname', 'pid', 'topic', 'action', 'cver',
     )
 
-    def __init__(self, c, enable_gossip=True, interval=5.0, **kwargs):
-        self.enabled = enable_gossip
+    def __init__(self, c, without_gossip=False, interval=5.0, **kwargs):
+        self.enabled = not without_gossip
         self.app = c.app
         c.gossip = self
         self.Receiver = c.app.events.Receiver
@@ -738,8 +738,8 @@ class Mingle(bootsteps.StartStopStep):
     label = 'Mingle'
     requires = (Gossip, )
 
-    def __init__(self, c, enable_mingle=True, **kwargs):
-        self.enabled = enable_mingle
+    def __init__(self, c, without_mingle=False, **kwargs):
+        self.enabled = not without_mingle
 
     def start(self, c):
         info('mingle: searching for neighbors')