Skip to content

Commit

Permalink
Use local copies in Fetcher._fetchable_partitions to avoid mutation e…
Browse files Browse the repository at this point in the history
…rrors (#1400)
  • Loading branch information
dpkp authored Mar 8, 2018
1 parent ff13f87 commit a6130d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kafka/consumer/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,12 @@ def _handle_offset_response(self, future, response):

def _fetchable_partitions(self):
fetchable = self._subscriptions.fetchable_partitions()
if self._next_partition_records:
fetchable.discard(self._next_partition_records.topic_partition)
for fetch in self._completed_fetches:
# do not fetch a partition if we have a pending fetch response to process
current = self._next_partition_records
pending = copy.copy(self._completed_fetches)
if current:
fetchable.discard(current.topic_partition)
for fetch in pending:
fetchable.discard(fetch.topic_partition)
return fetchable

Expand Down

0 comments on commit a6130d2

Please # to comment.