Skip to content

Do not block on sender thread join after timeout in producer.close() #1974

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

Merged
merged 2 commits into from
Dec 30, 2019
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
6 changes: 1 addition & 5 deletions kafka/producer/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _unregister_cleanup(self):
self._cleanup = None

def __del__(self):
self.close(timeout=0)
self.close()

def close(self, timeout=None):
"""Close this producer.
Expand Down Expand Up @@ -483,14 +483,10 @@ def close(self, timeout=None):
self._sender.join(timeout)

if self._sender is not None and self._sender.is_alive():

log.info("Proceeding to force close the producer since pending"
" requests could not be completed within timeout %s.",
timeout)
self._sender.force_close()
# Only join the sender thread when not calling from callback.
if not invoked_from_callback:
self._sender.join()

self._metrics.close()
try:
Expand Down