From 1549b269c500e0cc099c69eb31a3fed8cf18ce3b Mon Sep 17 00:00:00 2001 From: Ranjan Yadav Date: Tue, 13 Jan 2026 02:02:13 -0800 Subject: [PATCH] REF: Switch to deque.copy() for Python 3 compatibility --- kafka/consumer/fetcher.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kafka/consumer/fetcher.py b/kafka/consumer/fetcher.py index 8c2a41ba0..0b7c3b377 100644 --- a/kafka/consumer/fetcher.py +++ b/kafka/consumer/fetcher.py @@ -1,5 +1,4 @@ import collections -import copy import itertools import logging import sys @@ -611,8 +610,7 @@ def _fetchable_partitions(self): fetchable = self._subscriptions.fetchable_partitions() # do not fetch a partition if we have a pending fetch response to process # use copy.copy to avoid runtimeerror on mutation from different thread - # TODO: switch to deque.copy() with py3 - discard = {fetch.topic_partition for fetch in copy.copy(self._completed_fetches)} + discard = {fetch.topic_partition for fetch in self._completed_fetches.copy()} current = self._next_partition_records if current: discard.add(current.topic_partition)