diff options
author | Dana Powers <dana.powers@gmail.com> | 2016-03-23 09:59:52 -0700 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2016-04-05 00:16:16 -0700 |
commit | bb25469fdaf6e0bfe929f12173578e8fdf114094 (patch) | |
tree | c83a38ee159dadf55b0f88ae579b64f6d4bb1885 /kafka/conn.py | |
parent | 4a04a09ef1a7abc9085ab8208b62fbbfa6fc64bb (diff) | |
download | kafka-python-sock_send_bytes.tar.gz |
Handle partial socket send()sock_send_bytes
Diffstat (limited to 'kafka/conn.py')
-rw-r--r-- | kafka/conn.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kafka/conn.py b/kafka/conn.py index 2b82b6d..ffc839e 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -188,10 +188,12 @@ class BrokerConnection(object): # and send bytes asynchronously. For now, just block # sending each request payload self._sock.setblocking(True) - sent_bytes = self._sock.send(size) - assert sent_bytes == len(size) - sent_bytes = self._sock.send(message) - assert sent_bytes == len(message) + for data in (size, message): + total_sent = 0 + while total_sent < len(data): + sent_bytes = self._sock.send(data[total_sent:]) + total_sent += sent_bytes + assert total_sent == len(data) self._sock.setblocking(False) except (AssertionError, ConnectionError) as e: log.exception("Error sending %s to %s", request, self) |