mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-02-22 17:37:04 +00:00
Acquire pools with the 'with' statement
This commit is contained in:
parent
311e6c63e8
commit
fc0bd12631
@ -443,9 +443,8 @@ def system_status():
|
|||||||
self.items[-1]["extra"].append({ "text": message, "monospace": monospace })
|
self.items[-1]["extra"].append({ "text": message, "monospace": monospace })
|
||||||
output = WebOutput()
|
output = WebOutput()
|
||||||
# Create a temporary pool of processes for the status checks
|
# Create a temporary pool of processes for the status checks
|
||||||
pool = multiprocessing.pool.Pool(processes=5)
|
with multiprocessing.pool.Pool(processes=5) as pool:
|
||||||
run_checks(False, env, output, pool)
|
run_checks(False, env, output, pool)
|
||||||
pool.terminate()
|
|
||||||
return json_response(output.items)
|
return json_response(output.items)
|
||||||
|
|
||||||
@app.route('/system/updates')
|
@app.route('/system/updates')
|
||||||
|
@ -1036,14 +1036,12 @@ if __name__ == "__main__":
|
|||||||
env = load_environment()
|
env = load_environment()
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
pool = multiprocessing.pool.Pool(processes=10)
|
with multiprocessing.pool.Pool(processes=10) as pool:
|
||||||
run_checks(False, env, ConsoleOutput(), pool)
|
run_checks(False, env, ConsoleOutput(), pool)
|
||||||
pool.terminate()
|
|
||||||
|
|
||||||
elif sys.argv[1] == "--show-changes":
|
elif sys.argv[1] == "--show-changes":
|
||||||
pool = multiprocessing.pool.Pool(processes=10)
|
with multiprocessing.pool.Pool(processes=10) as pool:
|
||||||
run_and_output_changes(env, pool)
|
run_and_output_changes(env, pool)
|
||||||
pool.terminate()
|
|
||||||
|
|
||||||
elif sys.argv[1] == "--check-primary-hostname":
|
elif sys.argv[1] == "--check-primary-hostname":
|
||||||
# See if the primary hostname appears resolvable and has a signed certificate.
|
# See if the primary hostname appears resolvable and has a signed certificate.
|
||||||
|
Loading…
Reference in New Issue
Block a user