优化api请求时间

qrnn
youngS 3 years ago
parent 26e6efeaf4
commit 9d0d36ca63
  1. 2
      fir_ser/api/tasks.py
  2. 10
      fir_ser/api/utils/app/supersignutils.py
  3. 5
      fir_ser/api/utils/apple/appleapiv3.py
  4. 2
      fir_ser/config.py

@ -47,7 +47,7 @@ def run_sign_task(format_udid_info, short, client_ip):
elif code in [1004, 1001, 1009]:
msg = msg.get('msg', '未知错误')
else:
msg = '系统内部错误'
msg = '系统内部错误,请稍后再试或联系管理员'
else:
msg = ""
return msg

@ -663,7 +663,7 @@ class IosUtils(object):
add_new_bundles_prefix = f"check_or_add_new_bundles_{self.developer_obj.issuer_id}_{self.app_obj.app_id}"
download_profile_prefix = f"make_and_download_profile_{self.developer_obj.issuer_id}_{self.app_obj.app_id}"
with cache.lock(register_devices_prefix, timeout=60):
with cache.lock(register_devices_prefix, timeout=360):
if CleanErrorBundleIdSignDataState(add_new_bundles_prefix).get_state():
return True, True # 程序错误,进行清理的时候,拦截多余的设备注册
if not get_developer_obj_by_others(self.user_obj, self.udid, self.app_obj):
@ -674,14 +674,18 @@ class IosUtils(object):
self.udid_info, client_ip,
add_new_bundles_prefix)
if not status:
if 'UNEXPECTED_ERROR' in str(did_udid_result):
return False, {}
msg = f"app_id {self.app_obj} register devices failed. {did_udid_result}"
self.sign_failed_fun(d_result, msg)
continue
if status and 'continue' in [str(did_udid_result)]:
return True, True
with cache.lock(add_new_bundles_prefix, timeout=60):
with cache.lock(add_new_bundles_prefix, timeout=360):
status, bundle_result = IosUtils.check_or_add_new_bundles(self.app_obj, self.developer_obj)
if not status:
if 'UNEXPECTED_ERROR' in str(bundle_result):
return False, {}
msg = f"app_id {self.app_obj} create bundles failed. {bundle_result}"
self.sign_failed_fun(d_result, msg)
continue
@ -704,6 +708,8 @@ class IosUtils(object):
did_udid in
did_udid_lists])
if not status:
if 'UNEXPECTED_ERROR' in str(download_profile_result):
return False, {}
msg = f"app_id {self.app_obj} download profile failed. {download_profile_result}"
self.sign_failed_fun(d_result, msg)
continue

@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
proxies = settings.APPLE_DEVELOPER_API_PROXY if settings.APPLE_DEVELOPER_API_PROXY else {}
timeout = settings.APPLE_DEVELOPER_API_TIMEOUT if settings.APPLE_DEVELOPER_API_TIMEOUT else 180
timeout = settings.APPLE_DEVELOPER_API_TIMEOUT if settings.APPLE_DEVELOPER_API_TIMEOUT else 120
def request_format_log(req):
@ -784,6 +784,9 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
raise Exception(req.text)
elif req.status_code == 429: # 请求超过每小时限制 {'user-hour-lim': '3600', 'user-hour-rem': '3586'}
raise Exception(req.text)
elif req.status_code == 500:
time.sleep(60)
raise Exception(req.text)
else:
raise Exception('unknown error: %s code:%s' % (req.text, req.status_code))

@ -251,7 +251,7 @@ class IPACONF(object):
# 'http': '47.243.172.202:17897',
# 'https': '47.243.172.202:17897'
}
APPLE_DEVELOPER_API_TIMEOUT = 180 # 访问苹果api超时时间,默认3分钟
APPLE_DEVELOPER_API_TIMEOUT = 120 # 访问苹果api超时时间,默认3分钟
MOBILE_CONFIG_SIGN_SSL = {
# 描述文件是否签名,默认是关闭状态;如果开启,并且ssl_key_path 和 ssl_pem_path 正常,则使用填写的ssl进行签名,否则默认不签名
'open': True,

Loading…
Cancel
Save