diff options
Diffstat (limited to 'kafka/client.py')
-rw-r--r-- | kafka/client.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kafka/client.py b/kafka/client.py index 3de563c..46955e2 100644 --- a/kafka/client.py +++ b/kafka/client.py @@ -6,6 +6,7 @@ import functools import logging import random import time +import select from kafka.vendor import six @@ -279,6 +280,15 @@ class SimpleClient(object): conn = None while connections_by_future: futures = list(connections_by_future.keys()) + + # block until a socket is ready to be read + sockets = [ + conn._sock + for future, (conn, _) in six.iteritems(connections_by_future) + if not future.is_done and conn._sock is not None] + if sockets: + read_socks, _, _ = select.select(sockets, [], []) + for future in futures: if not future.is_done: |