Преглед изворни кода

Rate limits now work again

Ask Solem пре 12 година
родитељ
комит
5c6eee00bf

+ 3 - 0
celery/worker/__init__.py

@@ -190,6 +190,7 @@ class Queues(abstract.Component):
     requires = ("ev", )
 
     def create(self, w):
+        w.start_mediator = True
         if not w.pool_cls.rlimit_safe:
             w.disable_rate_limits = True
         if w.disable_rate_limits:
@@ -199,9 +200,11 @@ class Queues(abstract.Component):
                     w.ready_queue.put = w.process_task_sem
                 else:
                     w.ready_queue.put = w.process_task
+                    w.start_mediator = False
             elif not w.pool_cls.requires_mediator:
                 # just send task directly to pool, skip the mediator.
                 w.ready_queue.put = w.process_task
+                w.start_mediator = False
         else:
             w.ready_queue = TaskBucket(task_registry=w.app.tasks)
 

+ 1 - 3
celery/worker/mediator.py

@@ -39,9 +39,7 @@ class WorkerComponent(StartStopComponent):
         w.mediator = None
 
     def include_if(self, w):
-        return ((not w.disable_rate_limits or
-                w.pool_cls.requires_mediator) and
-                    not w.use_eventloop)
+        return w.start_mediator
 
     def create(self, w):
         m = w.mediator = self.instantiate(w.mediator_cls, w.ready_queue,

+ 2 - 2
docs/getting-started/first-steps-with-celery.rst

@@ -63,7 +63,7 @@ Let's create the file :file:`tasks.py`:
 
     from celery import Celery
 
-    celery = Celery("tasks", broker="amqp://guest:guest@localhost:5672")
+    celery = Celery("tasks", broker="amqp://guest@localhost//")
 
     @celery.task
     def add(x, y):
@@ -87,7 +87,7 @@ Running the celery worker server
 We can now run the worker by executing our program with the ``worker``
 argument::
 
-    $ python tasks.py worker --loglevel=INFO
+    $ python tasks.py worker --loglevel=info
 
 In production you will probably want to run the worker in the
 background as a daemon.  To do this you need to use the tools provided