Skip to content

Commit 3e8d1a3

Browse files
committed
Check that in-flight-request exists before processing received_bytes
1 parent 7ceaad5 commit 3e8d1a3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

kafka/conn.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,23 @@ def receive_bytes(self, data):
702702
def _process_response(self, read_buffer):
703703
assert not self._processing, 'Recursion not supported'
704704
self._processing = True
705-
ifr = self.in_flight_requests.popleft()
705+
recv_correlation_id = Int32.decode(read_buffer)
706+
707+
if not self.in_flight_requests:
708+
error = Errors.CorrelationIdError(
709+
'%s: No in-flight-request found for server response'
710+
' with correlation ID %d'
711+
% (self, recv_correlation_id))
712+
self.close(error)
713+
self._processing = False
714+
return None
715+
else:
716+
ifr = self.in_flight_requests.popleft()
717+
706718
if self._sensors:
707719
self._sensors.request_time.record((time.time() - ifr.timestamp) * 1000)
708720

709721
# verify send/recv correlation ids match
710-
recv_correlation_id = Int32.decode(read_buffer)
711722

712723
# 0.8.2 quirk
713724
if (self.config['api_version'] == (0, 8, 2) and

0 commit comments

Comments
 (0)