Ver código fonte

add a flag to disable Remote Control

pegler 11 anos atrás
pai
commit
0384c7f0c9
2 arquivos alterados com 8 adições e 3 exclusões
  1. 1 0
      celery/app/defaults.py
  2. 7 3
      celery/worker/consumer.py

+ 1 - 0
celery/app/defaults.py

@@ -112,6 +112,7 @@ NAMESPACES = {
         'DEFAULT_DELIVERY_MODE': Option(2, type='string'),
         'DEFAULT_DELIVERY_MODE': Option(2, type='string'),
         'EAGER_PROPAGATES_EXCEPTIONS': Option(False, type='bool'),
         'EAGER_PROPAGATES_EXCEPTIONS': Option(False, type='bool'),
         'ENABLE_UTC': Option(True, type='bool'),
         'ENABLE_UTC': Option(True, type='bool'),
+        'ENABLE_REMOTE_CONTROL': Option(True, type='bool'),
         'EVENT_SERIALIZER': Option('json'),
         'EVENT_SERIALIZER': Option('json'),
         'IMPORTS': Option((), type='tuple'),
         'IMPORTS': Option((), type='tuple'),
         'INCLUDE': Option((), type='tuple'),
         'INCLUDE': Option((), type='tuple'),

+ 7 - 3
celery/worker/consumer.py

@@ -146,7 +146,6 @@ class Consumer(object):
             'celery.worker.consumer:Events',
             'celery.worker.consumer:Events',
             'celery.worker.consumer:Gossip',
             'celery.worker.consumer:Gossip',
             'celery.worker.consumer:Heart',
             'celery.worker.consumer:Heart',
-            'celery.worker.consumer:Control',
             'celery.worker.consumer:Tasks',
             'celery.worker.consumer:Tasks',
             'celery.worker.consumer:Evloop',
             'celery.worker.consumer:Evloop',
             'celery.worker.consumer:Agent',
             'celery.worker.consumer:Agent',
@@ -202,9 +201,14 @@ class Consumer(object):
             # connect again.
             # connect again.
             self.app.conf.BROKER_CONNECTION_TIMEOUT = None
             self.app.conf.BROKER_CONNECTION_TIMEOUT = None
 
 
+        
+        additional_steps = None
+        if self.app.conf.CELERY_ENABLE_REMOTE_CONTROL:
+            additional_steps = ['celery.worker.consumer:Control']
+            
         self.steps = []
         self.steps = []
         self.blueprint = self.Blueprint(
         self.blueprint = self.Blueprint(
-            app=self.app, on_close=self.on_close,
+            app=self.app, on_close=self.on_close, steps=additional_steps,
         )
         )
         self.blueprint.apply(self, **dict(worker_options or {}, **kwargs))
         self.blueprint.apply(self, **dict(worker_options or {}, **kwargs))
 
 
@@ -487,7 +491,7 @@ class Control(bootsteps.StartStopStep):
 
 
 
 
 class Tasks(bootsteps.StartStopStep):
 class Tasks(bootsteps.StartStopStep):
-    requires = (Control, )
+    requires = ()
 
 
     def __init__(self, c, initial_prefetch_count=2, **kwargs):
     def __init__(self, c, initial_prefetch_count=2, **kwargs):
         c.task_consumer = c.qos = None
         c.task_consumer = c.qos = None