Skip to content

Commit

Permalink
perf: batch_request 添加数据异常处理逻辑 TencentBlueKing#7574
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Sep 26, 2024
1 parent 8b28b75 commit 921c9d8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions api/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

0 comments on commit 921c9d8

Please sign in to comment.