diff options
Diffstat (limited to 'kafka/client_async.py')
-rw-r--r-- | kafka/client_async.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/kafka/client_async.py b/kafka/client_async.py index 25ef29f..0f4863a 100644 --- a/kafka/client_async.py +++ b/kafka/client_async.py @@ -231,11 +231,15 @@ class KafkaClient(object): """ Returns the number of milliseconds to wait, based on the connection state, before attempting to send data. When disconnected, this respects - the reconnect backoff time. When connecting or connected, this handles - slow/stalled connections. + the reconnect backoff time. When connecting, returns 0 to allow + non-blocking connect to finish. When connected, returns a very large + number to handle slow/stalled connections. - @param node_id The id of the node to check - @return The number of milliseconds to wait. + Arguments: + node_id (int): The id of the node to check + + Returns: + int: The number of milliseconds to wait. """ if node_id not in self._conns: return 0 @@ -244,6 +248,8 @@ class KafkaClient(object): time_waited_ms = time.time() - (conn.last_attempt or 0) if conn.state is ConnectionStates.DISCONNECTED: return max(self.config['reconnect_backoff_ms'] - time_waited_ms, 0) + elif conn.state is ConnectionStates.CONNECTING: + return 0 else: return 999999999 |