summaryrefslogtreecommitdiff
path: root/kafka/conn.py
diff options
context:
space:
mode:
Diffstat (limited to 'kafka/conn.py')
-rw-r--r--kafka/conn.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/kafka/conn.py b/kafka/conn.py
index d778c31..ed11c3c 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -653,10 +653,13 @@ class BrokerConnection(object):
will be failed with this exception.
Default: kafka.errors.ConnectionError.
"""
+ if self.state is ConnectionStates.DISCONNECTED:
+ if error is not None:
+ log.warning('%s: Duplicate close() with error: %s', self, error)
+ return
log.info('%s: Closing connection. %s', self, error or '')
- if self.state is not ConnectionStates.DISCONNECTED:
- self.state = ConnectionStates.DISCONNECTING
- self.config['state_change_callback'](self)
+ self.state = ConnectionStates.DISCONNECTING
+ self.config['state_change_callback'](self)
self._update_reconnect_backoff()
self._close_socket()
self.state = ConnectionStates.DISCONNECTED