From 921c9d8fc5ebbfd2bdbaa34b01f7f7a5c84d6b91 Mon Sep 17 00:00:00 2001 From: waylon <1158341873@qq.com> Date: Thu, 26 Sep 2024 15:07:17 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20batch=5Frequest=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20#7574?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/utils/request.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/utils/request.py b/api/utils/request.py index 04170f48b4..2448c0973f 100644 --- a/api/utils/request.py +++ b/api/utils/request.py @@ -10,13 +10,15 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -from django.utils.translation import ugettext_lazy as _ import logging +from django.utils.translation import ugettext_lazy as _ + from gcloud.conf import settings from gcloud.exceptions import ApiRequestError from gcloud.iam_auth.utils import check_and_raise_raw_auth_fail_exception from gcloud.utils.handlers import handle_api_error + from .thread import ThreadPool logger = logging.getLogger("root") @@ -126,6 +128,11 @@ def batch_request( check_and_raise_raw_auth_fail_exception(result, message) raise ApiRequestError(message) - data.extend(get_data(result)) + try: + data.extend(get_data(result)) + except Exception as e: + message = handle_api_error("[batch_request get_data]", func.path, params_and_future["params"], result) + logger.exception(f"{e}: {message}") + raise ApiRequestError(message) return data