From ac322971600fad9ce21b574cf38543029881e9fd Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:28:54 -0700 Subject: [PATCH] Close database connection on garbage collection --- plexpy/database.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plexpy/database.py b/plexpy/database.py index 4762805f..e70d6c77 100644 --- a/plexpy/database.py +++ b/plexpy/database.py @@ -490,4 +490,8 @@ class MonitorDatabase(object): # Get the last insert row id result = self.select_single(query="SELECT last_insert_rowid() AS last_id") if result: - return result.get('last_id', None) \ No newline at end of file + return result.get('last_id', None) + + def __del__(self): + # Close the database connection when object is garbage collected + self.connection.close()