From 22e84a57cb0a33aef3b37ed0515a85244d3a1615 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Tue, 12 Jan 2016 14:43:49 -0800 Subject: Remove sleep call in client.poll -- expect callers to manage this and log warning --- kafka/client_async.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'kafka/client_async.py') diff --git a/kafka/client_async.py b/kafka/client_async.py index 88b8ec6..577229a 100644 --- a/kafka/client_async.py +++ b/kafka/client_async.py @@ -338,17 +338,16 @@ class KafkaClient(object): # select on reads across all connected sockets, blocking up to timeout sockets = dict([(conn._sock, conn) for conn in six.itervalues(self._conns) - if (conn.state is ConnectionStates.CONNECTED - and conn.in_flight_requests)]) + 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) + elif timeout: + log.warning('_poll called with a timeout, but nothing to do' + ' -- this can cause high CPU usage during idle') return [] ready, _, _ = select.select(list(sockets.keys()), [], [], timeout) -- cgit v1.2.1