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

client_async: Allow throwing an exception upon socket error during wakeup #2371

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Avoid 100% CPU usage while socket is closed (#156)
After stop/start kafka service, kafka-python may use 100% CPU caused by
busy-retry while the socket was closed. This fix the issue by unregister
the socket if the fd is negative.

Co-authored-by: Orange Kao <orange@aiven.io>
wbarnha and orange-kao authored Mar 9, 2024
commit cda8f81ae16ee087cd039a4277be13f2004d4d09
3 changes: 3 additions & 0 deletions kafka/client_async.py
Original file line number Diff line number Diff line change
@@ -637,6 +637,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)

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