From 2dd216b5acafb89d177a79ec779374c5a6f94dcf Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Thu, 18 Feb 2016 21:53:11 -0800 Subject: Some attributes may not exist in __del__ if we failed assertions --- kafka/coordinator/consumer.py | 2 +- kafka/producer/kafka.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kafka/coordinator/consumer.py b/kafka/coordinator/consumer.py index 97e8a99..e7a687e 100644 --- a/kafka/coordinator/consumer.py +++ b/kafka/coordinator/consumer.py @@ -103,7 +103,7 @@ class ConsumerCoordinator(BaseCoordinator): # self.sensors = ConsumerCoordinatorMetrics(metrics, metric_group_prefix, metric_tags) def __del__(self): - if self._auto_commit_task: + if hasattr(self, '_auto_commit_task') and self._auto_commit_task: self._auto_commit_task.disable() self._cluster.remove_listener(WeakMethod(self._handle_metadata_update)) diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py index 11eeddd..37cd9b6 100644 --- a/kafka/producer/kafka.py +++ b/kafka/producer/kafka.py @@ -270,7 +270,7 @@ class KafkaProducer(object): def close(self, timeout=None): """Close this producer.""" - if self._closed: + if not hasattr(self, '_closed') or self._closed: log.info('Kafka producer closed') return if timeout is None: -- cgit v1.2.1