diff --git a/management/daemon.py b/management/daemon.py index 17763039..cac8a134 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -443,9 +443,8 @@ def system_status(): self.items[-1]["extra"].append({ "text": message, "monospace": monospace }) output = WebOutput() # Create a temporary pool of processes for the status checks - pool = multiprocessing.pool.Pool(processes=5) - run_checks(False, env, output, pool) - pool.terminate() + with multiprocessing.pool.Pool(processes=5) as pool: + run_checks(False, env, output, pool) return json_response(output.items) @app.route('/system/updates') diff --git a/management/status_checks.py b/management/status_checks.py index 2d0b2c14..a44832fd 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -1036,14 +1036,12 @@ if __name__ == "__main__": env = load_environment() if len(sys.argv) == 1: - pool = multiprocessing.pool.Pool(processes=10) - run_checks(False, env, ConsoleOutput(), pool) - pool.terminate() + with multiprocessing.pool.Pool(processes=10) as pool: + run_checks(False, env, ConsoleOutput(), pool) elif sys.argv[1] == "--show-changes": - pool = multiprocessing.pool.Pool(processes=10) - run_and_output_changes(env, pool) - pool.terminate() + with multiprocessing.pool.Pool(processes=10) as pool: + run_and_output_changes(env, pool) elif sys.argv[1] == "--check-primary-hostname": # See if the primary hostname appears resolvable and has a signed certificate.