mirror of https://github.com/celery/kombu.git
ConsumerMixin: Connection error logs now include traceback. Closes #480
This commit is contained in:
parent
b6c3f99f66
commit
b4d8d860f1
|
@ -28,6 +28,14 @@ __all__ = ['ConsumerMixin']
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
debug, info, warn, error = logger.debug, logger.info, logger.warn, logger.error
|
debug, info, warn, error = logger.debug, logger.info, logger.warn, logger.error
|
||||||
|
|
||||||
|
W_CONN_LOST = """\
|
||||||
|
Connection to broker lost, trying to re-establish connection...\
|
||||||
|
"""
|
||||||
|
|
||||||
|
W_CONN_ERROR = """\
|
||||||
|
Broker connection error, trying again in %s seconds: %r.\
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ConsumerMixin(object):
|
class ConsumerMixin(object):
|
||||||
"""Convenience mixin for implementing consumer programs.
|
"""Convenience mixin for implementing consumer programs.
|
||||||
|
@ -153,8 +161,7 @@ class ConsumerMixin(object):
|
||||||
message.ack()
|
message.ack()
|
||||||
|
|
||||||
def on_connection_error(self, exc, interval):
|
def on_connection_error(self, exc, interval):
|
||||||
warn('Broker connection error: %r. '
|
warn(W_CONN_ERROR, interval, exc, exc_info=1)
|
||||||
'Trying again in %s seconds.', exc, interval)
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def extra_context(self, connection, channel):
|
def extra_context(self, connection, channel):
|
||||||
|
@ -172,8 +179,7 @@ class ConsumerMixin(object):
|
||||||
else:
|
else:
|
||||||
sleep(restart_limit.expected_time(_tokens))
|
sleep(restart_limit.expected_time(_tokens))
|
||||||
except errors:
|
except errors:
|
||||||
warn('Connection to broker lost. '
|
warn(W_CONN_LOST, exc_info=1)
|
||||||
'Trying to re-establish the connection...')
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def consumer_context(self, **kwargs):
|
def consumer_context(self, **kwargs):
|
||||||
|
|
Loading…
Reference in New Issue