in cdsreaper/messagesender.py [0:0]
def _setup_channel(self, attempt=1):
"""
sets up a channel via the given connection and ensures that the exchange is declared.
this is called at construction so you shouldn't need to call manually, and it is called again if the
connection is dropped.
this can throw any AMQP exceptions.
:return:
"""
try:
self._conn = pika.BlockingConnection(self._params)
self._channel = self._conn.channel()
self._channel.exchange_declare(self.exchange, exchange_type="topic",durable=True,auto_delete=False)
self._channel.confirm_delivery()
except pika.exceptions.AMQPError as e:
if attempt >= self.max_retry_attempts:
raise
retry_delay = 2*attempt
logger.error("Could not establish rabbitmq connection on attempt {0}: {1}. Retrying in {2}s".format(attempt, str(e), retry_delay))
time.sleep(retry_delay)
return self._setup_channel(attempt+1)