Update app.py
Browse files
app.py
CHANGED
@@ -1041,13 +1041,8 @@ def generate_avatar_animation(portrait_image, driving_audio, guidance_scale, inf
|
|
1041 |
try:
|
1042 |
logging.info(f"API μ°κ²° μλ {attempt + 1}/{max_retries}")
|
1043 |
|
1044 |
-
#
|
1045 |
-
|
1046 |
-
import httpx
|
1047 |
-
client = Client(
|
1048 |
-
AVATAR_API_URL,
|
1049 |
-
timeout=httpx.Timeout(60.0, connect=30.0) # μ°κ²° νμμμ 30μ΄, μ 체 νμμμ 60μ΄
|
1050 |
-
)
|
1051 |
|
1052 |
logging.info("API ν΄λΌμ΄μΈνΈ μμ± μ±κ³΅")
|
1053 |
|
@@ -1063,16 +1058,17 @@ def generate_avatar_animation(portrait_image, driving_audio, guidance_scale, inf
|
|
1063 |
# μ±κ³΅νλ©΄ 루ν μ’
λ£
|
1064 |
break
|
1065 |
|
1066 |
-
except (httpx.ConnectTimeout, httpx.TimeoutException) as e:
|
1067 |
-
logging.warning(f"μ°κ²° νμμμ (μλ {attempt + 1}/{max_retries}): {str(e)}")
|
1068 |
-
if attempt < max_retries - 1:
|
1069 |
-
logging.info(f"{retry_delay}μ΄ ν μ¬μλ...")
|
1070 |
-
time.sleep(retry_delay)
|
1071 |
-
else:
|
1072 |
-
return None, None, "β API μλ²μ μ°κ²°ν μ μμ΅λλ€. μ μ ν λ€μ μλν΄μ£ΌμΈμ."
|
1073 |
except Exception as e:
|
1074 |
-
|
1075 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1076 |
|
1077 |
# μμ νμΌ μμ (μλ κ²½μ°)
|
1078 |
if 'temp_portrait_path' in locals() and os.path.exists(temp_portrait_path):
|
@@ -1110,12 +1106,6 @@ def generate_avatar_animation(portrait_image, driving_audio, guidance_scale, inf
|
|
1110 |
logging.error(f"Unexpected API response: {result}")
|
1111 |
return None, None, "β API μλ΅μ΄ μμκ³Ό λ€λ¦
λλ€."
|
1112 |
|
1113 |
-
except httpx.ConnectTimeout:
|
1114 |
-
logging.error("Connection timeout to API server")
|
1115 |
-
return None, None, "β API μλ² μ°κ²° μκ° μ΄κ³Ό. μλ²κ° μλ΅νμ§ μμ΅λλ€."
|
1116 |
-
except httpx.TimeoutException:
|
1117 |
-
logging.error("Request timeout")
|
1118 |
-
return None, None, "β μμ² μκ° μ΄κ³Ό. μλ² μ²λ¦¬ μκ°μ΄ λ무 κΉλλ€."
|
1119 |
except Exception as e:
|
1120 |
logging.error(f"Avatar generation error: {str(e)}")
|
1121 |
import traceback
|
|
|
1041 |
try:
|
1042 |
logging.info(f"API μ°κ²° μλ {attempt + 1}/{max_retries}")
|
1043 |
|
1044 |
+
# κ°λ¨ν Client μμ± (timeout λ§€κ°λ³μ μμ΄)
|
1045 |
+
client = Client(AVATAR_API_URL)
|
|
|
|
|
|
|
|
|
|
|
1046 |
|
1047 |
logging.info("API ν΄λΌμ΄μΈνΈ μμ± μ±κ³΅")
|
1048 |
|
|
|
1058 |
# μ±κ³΅νλ©΄ 루ν μ’
λ£
|
1059 |
break
|
1060 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1061 |
except Exception as e:
|
1062 |
+
logging.warning(f"API νΈμΆ μ€λ₯ (μλ {attempt + 1}/{max_retries}): {str(e)}")
|
1063 |
+
if "Connection" in str(e) or "Timeout" in str(e):
|
1064 |
+
if attempt < max_retries - 1:
|
1065 |
+
logging.info(f"{retry_delay}μ΄ ν μ¬μλ...")
|
1066 |
+
time.sleep(retry_delay)
|
1067 |
+
else:
|
1068 |
+
return None, None, "β API μλ²μ μ°κ²°ν μ μμ΅λλ€. μ μ ν λ€μ μλν΄μ£ΌμΈμ."
|
1069 |
+
else:
|
1070 |
+
# λ€λ₯Έ μμΈλ μ¦μ μ²λ¦¬
|
1071 |
+
raise e
|
1072 |
|
1073 |
# μμ νμΌ μμ (μλ κ²½μ°)
|
1074 |
if 'temp_portrait_path' in locals() and os.path.exists(temp_portrait_path):
|
|
|
1106 |
logging.error(f"Unexpected API response: {result}")
|
1107 |
return None, None, "β API μλ΅μ΄ μμκ³Ό λ€λ¦
λλ€."
|
1108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1109 |
except Exception as e:
|
1110 |
logging.error(f"Avatar generation error: {str(e)}")
|
1111 |
import traceback
|