diff --git a/kafka/conn.py b/kafka/conn.py index af01efa14..16e923846 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -7,7 +7,7 @@ from random import shuffle, uniform import socket import time -import traceback +import sys from kafka.vendor import six @@ -614,8 +614,10 @@ def close(self, error=None): """ if self.state is ConnectionStates.DISCONNECTED: if error is not None: - log.warning('%s: close() called on disconnected connection with error: %s', self, error) - traceback.print_stack() + if sys.version_info >= (3, 2): + log.warning('%s: close() called on disconnected connection with error: %s', self, error, stack_info=True) + else: + log.warning('%s: close() called on disconnected connection with error: %s', self, error) return log.info('%s: Closing connection. %s', self, error or '')