Skip to content

Commit 41aa034

Browse files
authored
Fix pending completion IndexError bug caused by multiple threads (dpkp#1372)
1 parent 68068ca commit 41aa034

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

kafka/client_async.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,14 @@ def in_flight_request_count(self, node_id=None):
665665

666666
def _fire_pending_completed_requests(self):
667667
responses = []
668-
while self._pending_completion:
669-
response, future = self._pending_completion.popleft()
668+
while True:
669+
try:
670+
# We rely on deque.popleft remaining threadsafe
671+
# to allow both the heartbeat thread and the main thread
672+
# to process responses
673+
response, future = self._pending_completion.popleft()
674+
except IndexError:
675+
break
670676
future.success(response)
671677
responses.append(response)
672678
return responses

0 commit comments

Comments
 (0)