diff --git a/logzio/handler.py b/logzio/handler.py index 0b319f3..a4c741f 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -32,6 +32,9 @@ class LogzioHandler(logging.Handler): backup_logs=backup_logs) logging.Handler.__init__(self) + def __del__(self): + del self.logzio_sender + def extra_fields(self, message): not_allowed_keys = ( diff --git a/logzio/sender.py b/logzio/sender.py index 9c770a5..922d266 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -48,6 +48,11 @@ class LogzioSender: self.queue = queue.Queue() self._initialize_sending_thread() + def __del__(self): + del self.logger + del self.backup_logs + del self.queue + def _initialize_sending_thread(self): self.sending_thread = Thread(target=self._drain_queue) self.sending_thread.daemon = False @@ -153,6 +158,8 @@ class LogzioSender: 'backing up to local file system', number_of_retries) backup_logs(logs_list, self.logger) + del logs_list + def _get_messages_up_to_max_allowed_size(self): logs_list = [] current_size = 0