When using AMQP, if the AMQP server goes down this will now more nicely catch the Connection refused error in send_control_task

This commit is contained in:
Dannon Baker
2014-05-20 11:55:24 -04:00
parent b616072582
commit 034a1be99f
+10 -5
View File
@@ -70,11 +70,16 @@ def send_control_task(trans, task, noop_self=False, kwargs={}):
'kwargs': kwargs}
if noop_self:
payload['noop'] = trans.app.config.server_name
c = Connection(trans.app.config.amqp_internal_connection)
with producers[c].acquire(block=True) as producer:
producer.publish(payload, exchange=galaxy.queues.galaxy_exchange,
declare=[galaxy.queues.galaxy_exchange] + galaxy.queues.all_control_queues_for_declare(trans.app.config),
routing_key='control')
try:
c = Connection(trans.app.config.amqp_internal_connection)
with producers[c].acquire(block=True) as producer:
producer.publish(payload, exchange=galaxy.queues.galaxy_exchange,
declare=[galaxy.queues.galaxy_exchange] + galaxy.queues.all_control_queues_for_declare(trans.app.config),
routing_key='control')
except Exception:
# This is likely connection refused.
# TODO Use the specific Exception above.
log.exception("Error sending control task: %s." % payload)
# Tasks -- to be reorganized into a separate module as appropriate. This is