Skip to content

Commit caade20

Browse files
authored
Merge pull request #174 from salute-developers/fix/PNLP-7915_fix_IllegalStateError
PNLP-7915: fix IllegalStateError
2 parents bda0ede + 0956bf2 commit caade20

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

core/mq/kafka/kafka_consumer.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,6 @@ def __init__(self, config: Dict[str, Any], loop: AbstractEventLoop):
4242
self._consumer = AIOKafkaConsumer(**conf, loop=loop)
4343
loop.run_until_complete(self._consumer.start())
4444

45-
def on_assign_offset_end(self, consumer: AIOKafkaConsumer, partitions: List[TopicPartition]) -> None:
46-
for p in partitions:
47-
p.offset = consumer.last_stable_offset(p)
48-
self.on_assign_log(consumer, partitions)
49-
try:
50-
consumer.assign(partitions)
51-
except KafkaError as e:
52-
self._error_callback(e)
53-
54-
def on_coop_assign_offset_end(self, consumer: AIOKafkaConsumer, partitions: List[TopicPartition]) -> None:
55-
for p in partitions:
56-
p.offset = consumer.last_stable_offset(p)
57-
self.on_assign_log(consumer, partitions)
58-
consumer.assign(consumer.assignment().update(partitions))
59-
6045
def on_assign_log(self, consumer: AIOKafkaConsumer, partitions: List[TopicPartition]) -> None:
6146
log_level = "WARNING"
6247
params = {
@@ -77,19 +62,11 @@ def subscribe(self, topics: Optional[Iterable[str]] = None) -> None:
7762
try:
7863
self._consumer.subscribe(topics, listener=CoreConsumerRebalanceListener(
7964
consumer=self._consumer,
80-
on_assign_callback=(self.get_on_assign_callback() if self.assign_offset_end
81-
else self.on_assign_log)
65+
on_assign_callback=self.on_assign_log
8266
))
8367
except KafkaError as e:
8468
self._error_callback(e)
8569

86-
def get_on_assign_callback(self) -> Callable[[AIOKafkaConsumer, List[TopicPartition]], None]:
87-
if "cooperative" in self._config["conf"].get("partition_assignment_strategy", ""):
88-
callback = self.on_coop_assign_offset_end
89-
else:
90-
callback = self.on_assign_offset_end
91-
return callback
92-
9370
def unsubscribe(self) -> None:
9471
self._consumer.unsubscribe()
9572

0 commit comments

Comments
 (0)