def _cleanup_factory(self):
        """Build a cleanup clojure that doesn't increase our ref count"""
        _self = weakref.proxy(self)
        def wrapper():
            try:
                _self.close(timeout=0, null_logger=True)
            except (ReferenceError, AttributeError):
                pass
        return wrapper
Build a cleanup clojure that doesn't increase our ref count
kafka/producer/kafka.py