aboutsummaryrefslogtreecommitdiffhomepage
path: root/bazarr.py
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2024-01-10 23:04:23 -0500
committerGitHub <[email protected]>2024-01-10 23:04:23 -0500
commit0807bd99b956ee3abf18acc3bec43a87fc8b1530 (patch)
treea570c745999b588c5c21ef79cd1f4f6f2058cf61 /bazarr.py
parentc17d127323cd4c62a075e3c6d26719b700e73d5a (diff)
downloadbazarr-0807bd99b956ee3abf18acc3bec43a87fc8b1530.tar.gz
bazarr-0807bd99b956ee3abf18acc3bec43a87fc8b1530.zip
Fixed improper closing of resources on exit
Diffstat (limited to 'bazarr.py')
-rw-r--r--bazarr.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/bazarr.py b/bazarr.py
index e0f214f93..f5fc76bb8 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -52,22 +52,27 @@ dir_name = os.path.dirname(__file__)
def end_child_process(ep):
try:
- ep.kill()
+ if os.name != 'nt':
+ try:
+ ep.send_signal(signal.SIGINT)
+ except ProcessLookupError:
+ pass
+ else:
+ import win32api
+ import win32con
+ try:
+ win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, ep.pid)
+ except KeyboardInterrupt:
+ pass
except:
- pass
-
-def terminate_child_process(ep):
- try:
ep.terminate()
- except:
- pass
def start_bazarr():
script = [get_python_path(), "-u", os.path.normcase(os.path.join(dir_name, 'bazarr', 'main.py'))] + sys.argv[1:]
ep = subprocess.Popen(script, stdout=None, stderr=None, stdin=subprocess.DEVNULL)
atexit.register(end_child_process, ep=ep)
- signal.signal(signal.SIGTERM, lambda signal_no, frame: terminate_child_process(ep))
+ signal.signal(signal.SIGTERM, lambda signal_no, frame: end_child_process(ep))
def check_status():