Skip to content

Avoid 100% CPU usage while socket is closed #2091

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

Closed
3 changes: 3 additions & 0 deletions kafka/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ def _poll(self, timeout):
self._sensors.select_time.record((end_select - start_select) * 1000000000)

for key, events in ready:
if key.fileobj.fileno() < 0:
self._selector.unregister(key.fileobj)
Copy link
Owner

Choose a reason for hiding this comment

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

I think this needs to be more robust: we want to close the conn here if it is a BrokerConnection, which would then trigger an unregister. But it could also be the _wake_r socketpair, in which case we need to reset/rebuild the wake socketpair.


if key.fileobj is self._wake_r:
self._clear_wake_fd()
continue
Expand Down