Merge "Python 3 deprecated the logger.warn method in favor of warning"
This commit is contained in:
commit
e15c11c499
@ -168,9 +168,9 @@ class ObsoleteReplyQueuesCache(object):
|
|||||||
self._no_reply_log(reply_q, msg_id)
|
self._no_reply_log(reply_q, msg_id)
|
||||||
|
|
||||||
def _no_reply_log(self, reply_q, msg_id):
|
def _no_reply_log(self, reply_q, msg_id):
|
||||||
LOG.warn(_LW("%(reply_queue)s doesn't exists, drop reply to "
|
LOG.warning(_LW("%(reply_queue)s doesn't exists, drop reply to "
|
||||||
"%(msg_id)s"), {'reply_queue': reply_q,
|
"%(msg_id)s"), {'reply_queue': reply_q,
|
||||||
'msg_id': msg_id})
|
'msg_id': msg_id})
|
||||||
|
|
||||||
|
|
||||||
class AMQPListener(base.Listener):
|
class AMQPListener(base.Listener):
|
||||||
@ -251,11 +251,11 @@ class ReplyWaiters(object):
|
|||||||
def add(self, msg_id):
|
def add(self, msg_id):
|
||||||
self._queues[msg_id] = moves.queue.Queue()
|
self._queues[msg_id] = moves.queue.Queue()
|
||||||
if len(self._queues) > self._wrn_threshold:
|
if len(self._queues) > self._wrn_threshold:
|
||||||
LOG.warn(_LW('Number of call queues is greater than warning '
|
LOG.warning(_LW('Number of call queues is greater than warning '
|
||||||
'threshold: %(old_threshold)s. There could be a '
|
'threshold: %(old_threshold)s. There could be a '
|
||||||
'leak. Increasing threshold to: %(threshold)s'),
|
'leak. Increasing threshold to: %(threshold)s'),
|
||||||
{'old_threshold': self._wrn_threshold,
|
{'old_threshold': self._wrn_threshold,
|
||||||
'threshold': self._wrn_threshold * 2})
|
'threshold': self._wrn_threshold * 2})
|
||||||
self._wrn_threshold *= 2
|
self._wrn_threshold *= 2
|
||||||
|
|
||||||
def remove(self, msg_id):
|
def remove(self, msg_id):
|
||||||
|
@ -132,7 +132,8 @@ class Connection(object):
|
|||||||
self._send(message, topic)
|
self._send(message, topic)
|
||||||
message = None
|
message = None
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warn(_LW("Failed to publish a message of topic %s"), topic)
|
LOG.warning(_LW("Failed to publish a message of topic %s"),
|
||||||
|
topic)
|
||||||
current_retry += 1
|
current_retry += 1
|
||||||
if retry is not None and current_retry >= retry:
|
if retry is not None and current_retry >= retry:
|
||||||
LOG.exception(_LE("Failed to retry to send data "
|
LOG.exception(_LE("Failed to retry to send data "
|
||||||
@ -238,10 +239,10 @@ class OsloKafkaMessage(base.IncomingMessage):
|
|||||||
super(OsloKafkaMessage, self).__init__(listener, ctxt, message)
|
super(OsloKafkaMessage, self).__init__(listener, ctxt, message)
|
||||||
|
|
||||||
def requeue(self):
|
def requeue(self):
|
||||||
LOG.warn(_LW("requeue is not supported"))
|
LOG.warning(_LW("requeue is not supported"))
|
||||||
|
|
||||||
def reply(self, reply=None, failure=None, log_failure=True):
|
def reply(self, reply=None, failure=None, log_failure=True):
|
||||||
LOG.warn(_LW("reply is not supported"))
|
LOG.warning(_LW("reply is not supported"))
|
||||||
|
|
||||||
|
|
||||||
class KafkaListener(base.Listener):
|
class KafkaListener(base.Listener):
|
||||||
|
@ -438,15 +438,16 @@ class Connection(object):
|
|||||||
|
|
||||||
self._url = ''
|
self._url = ''
|
||||||
if self.fake_rabbit:
|
if self.fake_rabbit:
|
||||||
LOG.warn(_LW("Deprecated: fake_rabbit option is deprecated, set "
|
LOG.warning(_LW("Deprecated: fake_rabbit option is deprecated, "
|
||||||
"rpc_backend to kombu+memory or use the fake "
|
"set rpc_backend to kombu+memory or use the fake "
|
||||||
"driver instead."))
|
"driver instead."))
|
||||||
self._url = 'memory://%s/' % virtual_host
|
self._url = 'memory://%s/' % virtual_host
|
||||||
elif url.hosts:
|
elif url.hosts:
|
||||||
if url.transport.startswith('kombu+'):
|
if url.transport.startswith('kombu+'):
|
||||||
LOG.warn(_LW('Selecting the kombu transport through the '
|
LOG.warning(_LW('Selecting the kombu transport through the '
|
||||||
'transport url (%s) is a experimental feature '
|
'transport url (%s) is a experimental feature '
|
||||||
'and this is not yet supported.'), url.transport)
|
'and this is not yet supported.'),
|
||||||
|
url.transport)
|
||||||
if len(url.hosts) > 1:
|
if len(url.hosts) > 1:
|
||||||
random.shuffle(url.hosts)
|
random.shuffle(url.hosts)
|
||||||
for host in url.hosts:
|
for host in url.hosts:
|
||||||
@ -637,10 +638,10 @@ class Connection(object):
|
|||||||
|
|
||||||
current_pid = os.getpid()
|
current_pid = os.getpid()
|
||||||
if self._initial_pid != current_pid:
|
if self._initial_pid != current_pid:
|
||||||
LOG.warn(_LW("Process forked after connection established! "
|
LOG.warning(_LW("Process forked after connection established! "
|
||||||
"This can result in unpredictable behavior. "
|
"This can result in unpredictable behavior. "
|
||||||
"See: http://docs.openstack.org/developer/"
|
"See: http://docs.openstack.org/developer/"
|
||||||
"oslo.messaging/transport.html"))
|
"oslo.messaging/transport.html"))
|
||||||
self._initial_pid = current_pid
|
self._initial_pid = current_pid
|
||||||
|
|
||||||
if retry is None:
|
if retry is None:
|
||||||
@ -794,8 +795,8 @@ class Connection(object):
|
|||||||
if self.connection.supports_heartbeats:
|
if self.connection.supports_heartbeats:
|
||||||
return True
|
return True
|
||||||
elif not self._heartbeat_support_log_emitted:
|
elif not self._heartbeat_support_log_emitted:
|
||||||
LOG.warn(_LW("Heartbeat support requested but it is not supported "
|
LOG.warning(_LW("Heartbeat support requested but it is not "
|
||||||
"by the kombu driver or the broker"))
|
"supported by the kombu driver or the broker"))
|
||||||
self._heartbeat_support_log_emitted = True
|
self._heartbeat_support_log_emitted = True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -142,8 +142,8 @@ class Replies(pyngus.ReceiverEventHandler):
|
|||||||
del self._correlation[key]
|
del self._correlation[key]
|
||||||
receiver.message_accepted(handle)
|
receiver.message_accepted(handle)
|
||||||
else:
|
else:
|
||||||
LOG.warn(_LW("Can't find receiver for response msg id=%s, "
|
LOG.warning(_LW("Can't find receiver for response msg id=%s, "
|
||||||
"dropping!"), key)
|
"dropping!"), key)
|
||||||
receiver.message_modified(handle, True, True, None)
|
receiver.message_modified(handle, True, True, None)
|
||||||
|
|
||||||
def _update_credit(self):
|
def _update_credit(self):
|
||||||
|
@ -62,8 +62,8 @@ class SendTask(controller.Task):
|
|||||||
controller.request(self._target, self._request,
|
controller.request(self._target, self._request,
|
||||||
self._results_queue, self._wait_for_reply)
|
self._results_queue, self._wait_for_reply)
|
||||||
else:
|
else:
|
||||||
LOG.warn(_LW("Send request to %s aborted: TTL expired."),
|
LOG.warning(_LW("Send request to %s aborted: TTL expired."),
|
||||||
self._target)
|
self._target)
|
||||||
|
|
||||||
|
|
||||||
class ListenTask(controller.Task):
|
class ListenTask(controller.Task):
|
||||||
|
@ -301,7 +301,7 @@ class CheckForLoggingIssues(BaseASTChecker):
|
|||||||
# because:
|
# because:
|
||||||
# 1. We have code like this that we'll fix when dealing with the %:
|
# 1. We have code like this that we'll fix when dealing with the %:
|
||||||
# msg = _('....') % {}
|
# msg = _('....') % {}
|
||||||
# LOG.warn(msg)
|
# LOG.warning(msg)
|
||||||
# 2. We also do LOG.exception(e) in several places. I'm not sure
|
# 2. We also do LOG.exception(e) in several places. I'm not sure
|
||||||
# exactly what we should be doing about that.
|
# exactly what we should be doing about that.
|
||||||
if msg.id not in self.assignments:
|
if msg.id not in self.assignments:
|
||||||
|
@ -112,7 +112,7 @@ class _OrderedTask(object):
|
|||||||
|
|
||||||
while condition():
|
while condition():
|
||||||
if log_timer is not None and log_timer.expired():
|
if log_timer is not None and log_timer.expired():
|
||||||
LOG.warn(_LW('Possible hang: %s'), msg)
|
LOG.warning(_LW('Possible hang: %s'), msg)
|
||||||
LOG.debug(''.join(traceback.format_stack()))
|
LOG.debug(''.join(traceback.format_stack()))
|
||||||
# Only log once. After than we wait indefinitely without
|
# Only log once. After than we wait indefinitely without
|
||||||
# logging.
|
# logging.
|
||||||
@ -346,11 +346,11 @@ class MessageHandlingServer(service.ServiceBase, _OrderedTaskRunner):
|
|||||||
"""
|
"""
|
||||||
# Warn that restarting will be deprecated
|
# Warn that restarting will be deprecated
|
||||||
if self._started:
|
if self._started:
|
||||||
LOG.warn(_LW('Restarting a MessageHandlingServer is inherently '
|
LOG.warning(_LW('Restarting a MessageHandlingServer is inherently '
|
||||||
'racy. It is deprecated, and will become a noop in '
|
'racy. It is deprecated, and will become a noop '
|
||||||
'a future release of oslo.messaging. If you need to '
|
'in a future release of oslo.messaging. If you '
|
||||||
'restart MessageHandlingServer you should '
|
'need to restart MessageHandlingServer you should '
|
||||||
'instantiate a new object.'))
|
'instantiate a new object.'))
|
||||||
self._started = True
|
self._started = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -750,14 +750,14 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
# DEFAULT_LOG_AFTER
|
# DEFAULT_LOG_AFTER
|
||||||
|
|
||||||
log_event = threading.Event()
|
log_event = threading.Event()
|
||||||
mock_log.warn.side_effect = lambda _, __: log_event.set()
|
mock_log.warning.side_effect = lambda _, __: log_event.set()
|
||||||
|
|
||||||
# Call stop without calling start. We should log a wait after 1 second
|
# Call stop without calling start. We should log a wait after 1 second
|
||||||
thread = eventlet.spawn(self.server.stop)
|
thread = eventlet.spawn(self.server.stop)
|
||||||
log_event.wait()
|
log_event.wait()
|
||||||
|
|
||||||
# Redundant given that we already waited, but it's nice to assert
|
# Redundant given that we already waited, but it's nice to assert
|
||||||
self.assertTrue(mock_log.warn.called)
|
self.assertTrue(mock_log.warning.called)
|
||||||
thread.kill()
|
thread.kill()
|
||||||
|
|
||||||
@mock.patch.object(server_module, 'LOG')
|
@mock.patch.object(server_module, 'LOG')
|
||||||
@ -766,14 +766,14 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
# the number of seconds passed to log_after
|
# the number of seconds passed to log_after
|
||||||
|
|
||||||
log_event = threading.Event()
|
log_event = threading.Event()
|
||||||
mock_log.warn.side_effect = lambda _, __: log_event.set()
|
mock_log.warning.side_effect = lambda _, __: log_event.set()
|
||||||
|
|
||||||
# Call stop without calling start. We should log a wait after 1 second
|
# Call stop without calling start. We should log a wait after 1 second
|
||||||
thread = eventlet.spawn(self.server.stop, log_after=1)
|
thread = eventlet.spawn(self.server.stop, log_after=1)
|
||||||
log_event.wait()
|
log_event.wait()
|
||||||
|
|
||||||
# Redundant given that we already waited, but it's nice to assert
|
# Redundant given that we already waited, but it's nice to assert
|
||||||
self.assertTrue(mock_log.warn.called)
|
self.assertTrue(mock_log.warning.called)
|
||||||
thread.kill()
|
thread.kill()
|
||||||
|
|
||||||
@mock.patch.object(server_module, 'LOG')
|
@mock.patch.object(server_module, 'LOG')
|
||||||
@ -782,14 +782,14 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
# specified an absolute timeout
|
# specified an absolute timeout
|
||||||
|
|
||||||
log_event = threading.Event()
|
log_event = threading.Event()
|
||||||
mock_log.warn.side_effect = lambda _, __: log_event.set()
|
mock_log.warning.side_effect = lambda _, __: log_event.set()
|
||||||
|
|
||||||
# Call stop without calling start. We should log a wait after 1 second
|
# Call stop without calling start. We should log a wait after 1 second
|
||||||
thread = eventlet.spawn(self.server.stop, log_after=1, timeout=2)
|
thread = eventlet.spawn(self.server.stop, log_after=1, timeout=2)
|
||||||
log_event.wait()
|
log_event.wait()
|
||||||
|
|
||||||
# Redundant given that we already waited, but it's nice to assert
|
# Redundant given that we already waited, but it's nice to assert
|
||||||
self.assertTrue(mock_log.warn.called)
|
self.assertTrue(mock_log.warning.called)
|
||||||
thread.kill()
|
thread.kill()
|
||||||
|
|
||||||
def test_timeout_wait(self):
|
def test_timeout_wait(self):
|
||||||
@ -835,4 +835,4 @@ class TestServerLocking(test_utils.BaseTestCase):
|
|||||||
self.server.stop, log_after=0, timeout=2)
|
self.server.stop, log_after=0, timeout=2)
|
||||||
|
|
||||||
# We timed out. Ensure we didn't log anything.
|
# We timed out. Ensure we didn't log anything.
|
||||||
self.assertFalse(mock_log.warn.called)
|
self.assertFalse(mock_log.warning.called)
|
||||||
|
Loading…
Reference in New Issue
Block a user