From 0c20107334d12bff515c40979a0ae90af5125570 Mon Sep 17 00:00:00 2001 From: Roy <576477085@qq.com> Date: Thu, 20 Jun 2024 15:20:40 +0800 Subject: [PATCH 1/2] update asset lit for concurrent --- api/terminal/terminal/apps/assets/api.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/api/terminal/terminal/apps/assets/api.py b/api/terminal/terminal/apps/assets/api.py index b9e66d2..8805954 100644 --- a/api/terminal/terminal/apps/assets/api.py +++ b/api/terminal/terminal/apps/assets/api.py @@ -6,6 +6,7 @@ import logging import os.path import re +import concurrent.futures import ipaddress from talos.common import cache @@ -147,10 +148,18 @@ def list(self, CONF.asset.asset_field_password: 'password', CONF.asset.asset_field_desc: 'description' } - for permission in permissions: - expression_assets = self.list_asset_by_expression(permission['expression'], fields) - auth_asset_ids.extend([auth_asset['asset_id'] for auth_asset in permission['assets']]) - auth_asset_ids.extend([asset['id'] for asset in expression_assets]) + with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: + futures = [executor.submit(self.list_asset_by_expression, permission['expression'], fields) + for permission in permissions] + for future in concurrent.futures.as_completed(futures): + expression_assets = future.result() + auth_asset_ids.extend([asset['id'] for asset in expression_assets]) + for permission in permissions: + auth_asset_ids.extend([auth_asset['asset_id'] for auth_asset in permission['assets']]) + # for permission in permissions: + # expression_assets = self.list_asset_by_expression(permission['expression'], fields) + # auth_asset_ids.extend([auth_asset['asset_id'] for auth_asset in permission['assets']]) + # auth_asset_ids.extend([asset['id'] for asset in expression_assets]) auth_asset_ids = set(auth_asset_ids) datas = [] From 1993c5f926b62524e470acb41ec7204eaf4d64c6 Mon Sep 17 00:00:00 2001 From: Roy <576477085@qq.com> Date: Mon, 4 Nov 2024 14:22:41 +0800 Subject: [PATCH 2/2] update docker base image --- Dockerfile | 2 +- Dockerfile_standalone | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9f44b90..bd71211 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-slim +FROM python:3.8-slim-buster LABEL maintainer = "Webank CTB Team" # Install logrotate RUN sed -i 's/deb.debian.org/mirrors.tencentyun.com/g' /etc/apt/sources.list diff --git a/Dockerfile_standalone b/Dockerfile_standalone index 8800cae..b61ffc3 100644 --- a/Dockerfile_standalone +++ b/Dockerfile_standalone @@ -1,4 +1,4 @@ -FROM python:3.7-slim +FROM python:3.8-slim-buster LABEL maintainer = "Webank CTB Team" # Install logrotate RUN sed -i 's/deb.debian.org/mirrors.tencentyun.com/g' /etc/apt/sources.list