From 27868ac32eb1bae4dd3333bc4d988ab4d46d9dc0 Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 17 Mar 2021 19:39:50 +0800 Subject: [PATCH] improve uc --- spug_api/apps/deploy/utils.py | 3 ++- spug_api/apps/deploy/views.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spug_api/apps/deploy/utils.py b/spug_api/apps/deploy/utils.py index 954e917..f899b58 100644 --- a/spug_api/apps/deploy/utils.py +++ b/spug_api/apps/deploy/utils.py @@ -62,7 +62,8 @@ def _ext1_deploy(req, helper, env): extend = req.deploy.extend_obj env.update(SPUG_DST_DIR=extend.dst_dir) threads, latest_exception = [], None - with futures.ThreadPoolExecutor(max_workers=min(10, os.cpu_count() + 5)) as executor: + max_workers = min(10, os.cpu_count() * 4) if req.deploy.is_parallel else 1 + with futures.ThreadPoolExecutor(max_workers=max_workers) as executor: for h_id in json.loads(req.host_ids): env = AttrDict(env.items()) t = executor.submit(_deploy_ext1_host, req, helper, h_id, env) diff --git a/spug_api/apps/deploy/views.py b/spug_api/apps/deploy/views.py index 7c53d6b..e8e1565 100644 --- a/spug_api/apps/deploy/views.py +++ b/spug_api/apps/deploy/views.py @@ -247,7 +247,7 @@ def post_request_1(request): form.version = repository.version form.spug_version = repository.spug_version form.deploy_id = repository.deploy_id - form.host_ids = json.dumps(form.host_ids) + form.host_ids = json.dumps(sorted(form.host_ids)) if form.id: req = DeployRequest.objects.get(pk=form.id) is_required_notify = repository.deploy.is_audit and req.status == '-1'