|
@@ -529,6 +529,9 @@ def _process_one_task(row, runner):
|
|
|
|
|
|
|
|
max_threshold = round(drop_price_change_upper * runner.rate * 1.0) # 降价阈值要按汇率转人民币(四舍五入到整数)
|
|
max_threshold = round(drop_price_change_upper * runner.rate * 1.0) # 降价阈值要按汇率转人民币(四舍五入到整数)
|
|
|
|
|
|
|
|
|
|
+ if abs(max_threshold) < 10:
|
|
|
|
|
+ return None
|
|
|
|
|
+
|
|
|
result = results[0]
|
|
result = results[0]
|
|
|
# adult_price = result.get("adult_price")
|
|
# adult_price = result.get("adult_price")
|
|
|
# adult_tax = result.get("adult_tax")
|
|
# adult_tax = result.get("adult_tax")
|
|
@@ -671,12 +674,31 @@ def main():
|
|
|
if len(policy_list) > 0:
|
|
if len(policy_list) > 0:
|
|
|
# 这里批量一次性上传政策
|
|
# 这里批量一次性上传政策
|
|
|
payload = {"items": policy_list}
|
|
payload = {"items": policy_list}
|
|
|
- try:
|
|
|
|
|
- sync_policy(payload)
|
|
|
|
|
- logger.info(f"上传政策成功")
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
- logger.error(f"上传政策失败: {e}")
|
|
|
|
|
- logger.error(f"{traceback.format_exc()}")
|
|
|
|
|
|
|
+ max_attempts = 3
|
|
|
|
|
+ retryable_exceptions = (
|
|
|
|
|
+ requests.exceptions.ConnectionError,
|
|
|
|
|
+ requests.exceptions.ConnectTimeout,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ for attempt in range(1, max_attempts + 1):
|
|
|
|
|
+ try:
|
|
|
|
|
+ sync_policy(payload)
|
|
|
|
|
+ logger.info(f"上传政策成功")
|
|
|
|
|
+ break
|
|
|
|
|
+ except retryable_exceptions as e:
|
|
|
|
|
+ if attempt == max_attempts:
|
|
|
|
|
+ logger.error(f"上传政策失败(已重试{max_attempts}次): {e}")
|
|
|
|
|
+ # logger.error(f"{traceback.format_exc()}")
|
|
|
|
|
+ else:
|
|
|
|
|
+ wait_seconds = attempt
|
|
|
|
|
+ logger.warning(
|
|
|
|
|
+ f"上传政策连接异常,第{attempt}/{max_attempts}次失败: {e},{wait_seconds}s后重试"
|
|
|
|
|
+ )
|
|
|
|
|
+ time.sleep(wait_seconds)
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ logger.error(f"上传政策失败(非连接异常,不重试): {e}")
|
|
|
|
|
+ logger.error(f"{traceback.format_exc()}")
|
|
|
|
|
+ break
|
|
|
|
|
|
|
|
logger.info(f"keep_info_end: {len(keep_info_end)}")
|
|
logger.info(f"keep_info_end: {len(keep_info_end)}")
|
|
|
|
|
|