Remove sleep call in client.poll -- expect callers to manage this and log warning
This commit is contained in:
@@ -338,17 +338,16 @@ class KafkaClient(object):
|
|||||||
# select on reads across all connected sockets, blocking up to timeout
|
# select on reads across all connected sockets, blocking up to timeout
|
||||||
sockets = dict([(conn._sock, conn)
|
sockets = dict([(conn._sock, conn)
|
||||||
for conn in six.itervalues(self._conns)
|
for conn in six.itervalues(self._conns)
|
||||||
if (conn.state is ConnectionStates.CONNECTED
|
if conn.state is ConnectionStates.CONNECTED
|
||||||
and conn.in_flight_requests)])
|
and conn.in_flight_requests])
|
||||||
if not sockets:
|
if not sockets:
|
||||||
# if sockets are connecting, we can wake when they are writeable
|
# if sockets are connecting, we can wake when they are writeable
|
||||||
if self._connecting:
|
if self._connecting:
|
||||||
sockets = [self._conns[node]._sock for node in self._connecting]
|
sockets = [self._conns[node]._sock for node in self._connecting]
|
||||||
select.select([], sockets, [], timeout)
|
select.select([], sockets, [], timeout)
|
||||||
# otherwise just sleep to prevent CPU spinning
|
elif timeout:
|
||||||
else:
|
log.warning('_poll called with a timeout, but nothing to do'
|
||||||
log.debug('Nothing to do in _poll -- sleeping for %s', timeout)
|
' -- this can cause high CPU usage during idle')
|
||||||
time.sleep(timeout)
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
ready, _, _ = select.select(list(sockets.keys()), [], [], timeout)
|
ready, _, _ = select.select(list(sockets.keys()), [], [], timeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user