From 8f10cc31532eb09d27b12f74eb886c40e7502a61 Mon Sep 17 00:00:00 2001 From: fstefanak Date: Thu, 21 Mar 2019 08:57:40 +0100 Subject: [PATCH] kafka-python #1748 Fix race condition in protocol.send_bytes --- kafka/conn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kafka/conn.py b/kafka/conn.py index e857d0ac5..28f9f3c38 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -790,7 +790,8 @@ def send_pending_requests(self): if self.state not in (ConnectionStates.AUTHENTICATING, ConnectionStates.CONNECTED): return Errors.NodeNotReadyError(str(self)) - data = self._protocol.send_bytes() + with self._lock: + data = self._protocol.send_bytes() try: # In the future we might manage an internal write buffer # and send bytes asynchronously. For now, just block