Skip to content

Commit 0a762a0

Browse files
author
Dana Powers
committed
socket.sendall should always raise an exception on error; remove extra return val check in KafkaConnection.send()
1 parent dac157a commit 0a762a0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

kafka/conn.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,15 @@ def _read_bytes(self, num_bytes):
106106

107107
def send(self, request_id, payload):
108108
"Send a request to Kafka"
109+
109110
log.debug("About to send %d bytes to Kafka, request %d" % (len(payload), request_id))
111+
112+
# Make sure we have a connection
113+
if self._dirty or not self._sock:
114+
self.reinit()
115+
110116
try:
111-
if self._dirty or not self._sock:
112-
self.reinit()
113-
log.debug("Sending payload %s" % (payload,))
114-
sent = self._sock.sendall(payload)
115-
if sent is not None:
116-
self._raise_connection_error()
117+
self._sock.sendall(payload)
117118
except socket.error:
118119
log.exception('Unable to send payload to Kafka')
119120
self._raise_connection_error()

0 commit comments

Comments
 (0)