diff options
author | Dana Powers <dana.powers@rd.io> | 2016-01-12 14:43:49 -0800 |
---|---|---|
committer | Dana Powers <dana.powers@rd.io> | 2016-01-12 14:43:49 -0800 |
commit | 22e84a57cb0a33aef3b37ed0515a85244d3a1615 (patch) | |
tree | 51f5c74b1d3733f5f0f19d281696959831d0cbfe /kafka/client_async.py | |
parent | dcd62b72e39df00da23e13d783fa5681a20e381b (diff) | |
download | kafka-python-22e84a57cb0a33aef3b37ed0515a85244d3a1615.tar.gz |
Remove sleep call in client.poll -- expect callers to manage this and log warning
Diffstat (limited to 'kafka/client_async.py')
-rw-r--r-- | kafka/client_async.py | 11 |
1 files changed, 5 insertions, 6 deletions
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) |