summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kafka/client_async.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/kafka/client_async.py b/kafka/client_async.py
index 1c74c6f..fa498e9 100644
--- a/kafka/client_async.py
+++ b/kafka/client_async.py
@@ -334,6 +334,14 @@ class KafkaClient(object):
if (conn.state is ConnectionStates.CONNECTED
and conn.in_flight_requests)])
if not sockets:
+ # if sockets are connecting, we can wake when they are writeable
+ if self._connecting:
+ sockets = [self._conns[node]._sock for node in self._connecting]
+ select.select([], sockets, [], timeout)
+ # otherwise just sleep to prevent CPU spinning
+ else:
+ log.debug('Nothing to do in _poll -- sleeping for %s', timeout)
+ time.sleep(timeout)
return []
ready, _, _ = select.select(list(sockets.keys()), [], [], timeout)