Преглед на файлове

Always set Producer(auto_declare=False)

Ask Solem преди 8 години
родител
ревизия
590aa85683
променени са 5 файла, в които са добавени 6 реда и са изтрити 4 реда
  1. 1 1
      celery/app/base.py
  2. 1 1
      celery/beat.py
  3. 1 1
      celery/contrib/migrate.py
  4. 2 1
      celery/events/dispatcher.py
  5. 1 0
      celery/task/base.py

+ 1 - 1
celery/app/base.py

@@ -710,7 +710,7 @@ class Celery(object):
         )
 
         if connection:
-            producer = amqp.Producer(connection)
+            producer = amqp.Producer(connection, auto_declare=False)
         with self.producer_or_acquire(producer) as P:
             with P.connection._reraise_as_library_errors():
                 self.backend.on_task_call(P, task_id)

+ 1 - 1
celery/beat.py

@@ -387,7 +387,7 @@ class Scheduler(object):
 
     @cached_property
     def producer(self):
-        return self.Producer(self._ensure_connected())
+        return self.Producer(self._ensure_connected(), auto_declare=False)
 
     @property
     def info(self):

+ 1 - 1
celery/contrib/migrate.py

@@ -102,7 +102,7 @@ def migrate_tasks(source, dest, migrate=migrate_task, app=None,
     """Migrate tasks from one broker to another."""
     app = app_or_default(app)
     queues = prepare_queues(queues)
-    producer = app.amqp.Producer(dest)
+    producer = app.amqp.Producer(dest, auto_declare=False)
     migrate = partial(migrate, producer, queues=queues)
 
     def on_declare_queue(queue):

+ 2 - 1
celery/events/dispatcher.py

@@ -102,7 +102,8 @@ class EventDispatcher(object):
     def enable(self):
         self.producer = Producer(self.channel or self.connection,
                                  exchange=self.exchange,
-                                 serializer=self.serializer)
+                                 serializer=self.serializer,
+                                 auto_declare=False)
         self.enabled = True
         for callback in self.on_enabled:
             callback()

+ 1 - 0
celery/task/base.py

@@ -219,6 +219,7 @@ class Task(BaseTask):
             connection,
             exchange=exchange and Exchange(exchange, exchange_type),
             routing_key=self.routing_key, **options
+            auto_declare=False,
         )
 
     @classmethod