diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 1f64536b6..9e966f503 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()