Explorar o código

celery.events.EventDispatcher: Don't create amqp channel if events disabled

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

+ 4 - 1
celery/events.py

@@ -38,11 +38,14 @@ class EventDispatcher(object):
     def __init__(self, connection, hostname=None, enabled=True,
             publisher=None):
         self.connection = connection
-        self.publisher = publisher or EventPublisher(self.connection)
         self.hostname = hostname or socket.gethostname()
         self.enabled = enabled
         self._lock = threading.Lock()
 
+        self.publisher = None
+        if self.enabled:
+            self.publisher = publisher or EventPublisher(self.connection)
+
     def send(self, type, **fields):
         """Send event.