Avoid some exceptions in Coordinator.__del__

This commit is contained in:
Dana Powers
2016-04-25 11:59:38 -07:00
parent 1bc2ce0778
commit 37cffc3327
2 changed files with 4 additions and 2 deletions

View File

@@ -89,6 +89,7 @@ class BaseCoordinator(object):
#self.sensors = GroupCoordinatorMetrics(metrics, metric_group_prefix, metric_tags)
def __del__(self):
if hasattr(self, 'heartbeat_task') and self.heartbeat_task:
self.heartbeat_task.disable()
@abc.abstractmethod

View File

@@ -106,6 +106,7 @@ class ConsumerCoordinator(BaseCoordinator):
def __del__(self):
if hasattr(self, '_auto_commit_task') and self._auto_commit_task:
self._auto_commit_task.disable()
if hasattr(self, '_cluster') and self._cluster:
self._cluster.remove_listener(WeakMethod(self._handle_metadata_update))
def protocol_type(self):