|
@@ -397,13 +397,22 @@ class Consumer(object):
|
|
self.pool.flush()
|
|
self.pool.flush()
|
|
|
|
|
|
def connect(self):
|
|
def connect(self):
|
|
- """Establish the broker connection.
|
|
+ """Establish the broker connection used for consuming tasks.
|
|
|
|
|
|
Retries establishing the connection if the
|
|
Retries establishing the connection if the
|
|
:setting:`broker_connection_retry` setting is enabled
|
|
:setting:`broker_connection_retry` setting is enabled
|
|
"""
|
|
"""
|
|
- conn = self.app.connection_for_read(heartbeat=self.amqheartbeat)
|
|
+ return self.connection_for_read(heartbeat=self.amqheartbeat)
|
|
|
|
|
|
|
|
+ def connection_for_read(self, heartbeat=None):
|
|
|
|
+ return self.ensure_connected(
|
|
|
|
+ self.app.connection_for_read(heartbeat=heartbeat))
|
|
|
|
+
|
|
|
|
+ def connection_for_write(self, heartbeat=None):
|
|
|
|
+ return self.ensure_connected(
|
|
|
|
+ self.app.connection_for_write(heartbeat=heartbeat))
|
|
|
|
+
|
|
|
|
+ def ensure_connected(self, conn):
|
|
|
|
|
|
|
|
|
|
def _error_handler(exc, interval, next_step=CONNECTION_RETRY_STEP):
|
|
def _error_handler(exc, interval, next_step=CONNECTION_RETRY_STEP):
|
|
@@ -427,6 +436,7 @@ class Consumer(object):
|
|
conn.transport.register_with_event_loop(conn.connection, self.hub)
|
|
conn.transport.register_with_event_loop(conn.connection, self.hub)
|
|
return conn
|
|
return conn
|
|
|
|
|
|
|
|
+
|
|
def _flush_events(self):
|
|
def _flush_events(self):
|
|
if self.event_dispatcher:
|
|
if self.event_dispatcher:
|
|
self.event_dispatcher.flush()
|
|
self.event_dispatcher.flush()
|