From 9b9f3b0a69b37324cac1f30363df267ae278f9c5 Mon Sep 17 00:00:00 2001 From: iloveicedgreentea <31193909+iloveicedgreentea@users.noreply.github.com> Date: Thu, 19 Jan 2023 19:49:39 -0500 Subject: [PATCH] fix closing conn if closed --- madvr/madvr.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/madvr/madvr.py b/madvr/madvr.py index 285ea9e..dc7678a 100644 --- a/madvr/madvr.py +++ b/madvr/madvr.py @@ -100,8 +100,18 @@ def _clear_attr(self) -> None: def close_connection(self) -> None: """close the connection""" - self.client.close() - self.notification_client.close() + try: + self.client.close() + except AttributeError: + # means its already closed + pass + + try: + self.notification_client.close() + except AttributeError: + # means its already closed + pass + self.is_closed = True # Clear attr