From 5d642ce2e6e1c126bdf5b2fbb1596ef7ced9d6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 21 Aug 2019 13:57:43 -0400 Subject: [PATCH] Continuing development. --- bazarr/database.py | 12 +++++------- bazarr/main.py | 5 +++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bazarr/database.py b/bazarr/database.py index 17e9fc619..e04672776 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -1,10 +1,8 @@ import os -import atexit from get_args import args from peewee import * from playhouse.sqliteq import SqliteQueueDatabase -from playhouse.reflection import generate_models from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie @@ -168,11 +166,6 @@ class TableSettingsNotifier(BaseModel): table_name = 'table_settings_notifier' -@atexit.register -def _stop_worker_threads(): - database.stop() - - def database_init(): database.start() database.connect() @@ -190,3 +183,8 @@ def database_init(): System.configured: 0 } ).execute() + + +def database_close(): + if not database.is_closed(): + database.close() diff --git a/bazarr/main.py b/bazarr/main.py index 9be15722a..caaea85e2 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -22,8 +22,8 @@ import operator from get_args import args from init import * -from database import database_init, TableEpisodes, TableShows, TableMovies, TableHistory, TableHistoryMovie, \ - TableSettingsLanguages, TableSettingsNotifier, System +from database import database_init, database_close, TableEpisodes, TableShows, TableMovies, TableHistory, \ + TableHistoryMovie, TableSettingsLanguages, TableSettingsNotifier, System # Initiate database database_init() @@ -187,6 +187,7 @@ def shutdown(): else: stop_file.write('') stop_file.close() + database_close() server.stop()