Revision f2bdb9ab logic/amqp_connection.py
b/logic/amqp_connection.py | ||
---|---|---|
31 | 31 |
import socket |
32 | 32 |
from amqplib import client_0_8 as amqp |
33 | 33 |
from django.conf import settings |
34 |
from synnefo.logic import log |
|
34 | 35 |
|
35 | 36 |
_conn = None |
36 | 37 |
_chan = None |
38 |
_logger = log.get_logger("amqplib") |
|
37 | 39 |
|
38 | 40 |
def _connect(): |
39 | 41 |
global _conn, _chan |
... | ... | |
76 | 78 |
exchange=exchange, |
77 | 79 |
routing_key=key) |
78 | 80 |
return |
79 |
except socket.error: |
|
80 |
#logger.exception("Server went away, reconnecting...")
|
|
81 |
except socket.error as se:
|
|
82 |
_logger.exception("Server went away, reconnecting...")
|
|
81 | 83 |
_connect() |
82 | 84 |
except Exception as e: |
83 | 85 |
if _conn is None: |
84 | 86 |
_connect() |
85 | 87 |
else: |
86 |
#self.logger.exception("Caught unexpected exception (msg: %s)", msg) |
|
87 |
raise AMQPError("Error sending message to exchange %s with key %s. Payload: %s. Error was: %s", |
|
88 |
(exchange, key, payload, e.message)) |
|
88 |
_logger.exception('Caught unexpected exception (msg: %s)'%msg) |
|
89 |
raise AMQPError("Error sending message to exchange %s with \ |
|
90 |
key %s.Payload: %s. Error was: %s", |
|
91 |
(exchange, key, payload, e.message)) |
|
92 |
|
|
89 | 93 |
|
90 | 94 |
def __init__(): |
91 | 95 |
_connect() |
Also available in: Unified diff