1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-20 02:52:11 +00:00

Acquire pools with the 'with' statement

This commit is contained in:
David Duque 2020-07-22 01:10:16 +01:00
parent b4fd79673b
commit f9c766f237
No known key found for this signature in database
GPG Key ID: 2F327738A3C0AE3A
2 changed files with 6 additions and 7 deletions

View File

@ -437,9 +437,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')

View File

@ -1023,12 +1023,12 @@ if __name__ == "__main__":
env = load_environment()
if len(sys.argv) == 1:
pool = multiprocessing.pool.Pool(processes=10)
run_checks(False, env, ConsoleOutput(), pool)
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)
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.