Catch amqp.exception.AccessRefused in taiga.events backend
parent
ba7f9b2096
commit
ad60ac2235
|
@ -17,6 +17,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from amqp import Connection as AmqpConnection
|
from amqp import Connection as AmqpConnection
|
||||||
|
from amqp.exceptions import AccessRefused
|
||||||
from amqp.basic_message import Message as AmqpMessage
|
from amqp.basic_message import Message as AmqpMessage
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
@ -53,8 +54,13 @@ class EventsPushBackend(base.BaseEventsPushBackend):
|
||||||
try:
|
try:
|
||||||
connection.connect()
|
connection.connect()
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
log.error("EventsPushBackend: Unable to connect with RabbitMQ at {}".format(self.url),
|
err_msg = "EventsPushBackend: Unable to connect with RabbitMQ (connection refused) at {}".format(
|
||||||
exc_info=True)
|
self.url)
|
||||||
|
log.error(err_msg, exc_info=True)
|
||||||
|
except AccessRefused:
|
||||||
|
err_msg = "EventsPushBackend: Unable to connect with RabbitMQ (access refused) at {}".format(
|
||||||
|
self.url)
|
||||||
|
log.error(err_msg, exc_info=True)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
message = AmqpMessage(message)
|
message = AmqpMessage(message)
|
||||||
|
@ -64,7 +70,6 @@ class EventsPushBackend(base.BaseEventsPushBackend):
|
||||||
rchannel.basic_publish(message, routing_key=routing_key, exchange=channel)
|
rchannel.basic_publish(message, routing_key=routing_key, exchange=channel)
|
||||||
rchannel.close()
|
rchannel.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error("EventsPushBackend: Unhandled exception",
|
log.error("EventsPushBackend: Unhandled exception", exc_info=True)
|
||||||
exc_info=True)
|
|
||||||
finally:
|
finally:
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
Loading…
Reference in New Issue