diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index dd1cc508c..1e51f1cf1 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -469,6 +469,8 @@ def close(self, timeout=None): timeout (float, optional): timeout in seconds to wait for completion. """ + # If there are any pending messages, send them now + self.flush(timeout) # drop our atexit handler now to avoid leaks self._unregister_cleanup()