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

Reduce internal client poll timeout for consumer iterator interface #1824

Merged
merged 2 commits into from
Aug 16, 2019

Conversation

dpkp
Copy link
Owner

@dpkp dpkp commented May 29, 2019

Another PR attempting to address heartbeat timing issues in consumers, especially with the iterator interface. Here we can reduce the client.poll timeout to at most the retry backoff (typically 100ms) so that the consumer iterator interface doesn't block for longer than the heartbeat timeout.


This change is Reviewable

@dpkp dpkp changed the title Reduce internal client poll timeout for consumer interator interface Reduce internal client poll timeout for consumer iterator interface May 29, 2019
@@ -1070,8 +1070,7 @@ def _message_generator(self):
self._update_fetch_positions(partitions)

poll_ms = 1000 * (self._consumer_timeout - time.time())
if not self._fetcher.in_flight_fetches():
poll_ms = min(poll_ms, self.config['reconnect_backoff_ms'])
poll_ms = min(poll_ms, self.config['retry_backoff_ms'])
Copy link
Collaborator

@jeffwidman jeffwidman May 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably do this as a one-liner combined with the line above (https://github.com/dpkp/kafka-python/pull/1824/files#diff-9da855eb60eed8ecc72ce217c25e576cR1072)... I think it's easier to mentally think through the calculated value that way:

poll_ms = min((1000 * (self._consumer_timeout - time.time())), self.config['retry_backoff_ms'])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed this as an additional commit... feel free to either squash or if you really don't like it then just drop that particular commit.

@jeffwidman jeffwidman merged commit 5bc2529 into master Aug 16, 2019
@jeffwidman jeffwidman deleted the lower_consumer_timeout branch August 16, 2019 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants