From 660d1fb1ff32e6447fc1366c79d746ff6646f6cf Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 18 Feb 2023 13:59:10 +0100 Subject: [PATCH] Fix for infinite creation of subprocesses on restart --- cps/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/server.py b/cps/server.py index 6b5ac761..45673102 100644 --- a/cps/server.py +++ b/cps/server.py @@ -153,7 +153,7 @@ class WebServer(object): # The value of __package__ indicates how Python was called. It may # not exist if a setuptools script is installed as an egg. It may be # set incorrectly for entry points created with pip on Windows. - if getattr(__main__, "__package__", None) is None or ( + if getattr(__main__, "__package__", "") == "" or ( os.name == "nt" and __main__.__package__ == "" and not os.path.exists(py_script) @@ -263,7 +263,10 @@ class WebServer(object): log.info("Performing restart of Calibre-Web") args = self._get_args_for_reloading() - subprocess.call(args, close_fds=True) # nosec + if os.environ.get('FLASK_DEBUG'): + subprocess.run(args, close_fds=True) # nosec + else: + subprocess.Popen(args, close_fds=True) # nosec return True @staticmethod