Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve send performance (#943) #946

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions aiokafka/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,25 +626,25 @@
UnknownTopicOrPartitionError: if no topic or partitions found
in cluster metadata
"""
if topic in self.cluster.topics():
return self.cluster.partitions_for_topic(topic)
partitions = self.cluster.partitions_for_topic(topic)
if partitions is not None:
return partitions

Check warning on line 631 in aiokafka/client.py

View check run for this annotation

Codecov / codecov/patch

aiokafka/client.py#L629-L631

Added lines #L629 - L631 were not covered by tests

# add topic to metadata topic list if it is not there already.
self.add_topic(topic)

t0 = time.monotonic()
while True:
await self.force_metadata_update()
if topic in self.cluster.topics():
break
partitions = self.cluster.partitions_for_topic(topic)
if partitions is not None:
return partitions

Check warning on line 641 in aiokafka/client.py

View check run for this annotation

Codecov / codecov/patch

aiokafka/client.py#L639-L641

Added lines #L639 - L641 were not covered by tests
if (time.monotonic() - t0) > (self._request_timeout_ms / 1000):
raise UnknownTopicOrPartitionError()
if topic in self.cluster.unauthorized_topics:
raise Errors.TopicAuthorizationFailedError(topic)
await asyncio.sleep(self._retry_backoff)

return self.cluster.partitions_for_topic(topic)

async def _maybe_wait_metadata(self):
if self._md_update_fut is not None:
await asyncio.shield(self._md_update_fut)
Expand Down
Loading