fix: 直接上传multipart超时 — connect timeout 10s→120s

requests/urllib3 发送 multipart body 期间 socket timeout 取的是
connect timeout 值而非 read timeout,跨境 1.4MB/s 下 17MB 视频需
~117s,原 10s 上限导致 100% 超时重试耗尽标记 FAILED。实测 task
50/51 修复后直接上传成功。
This commit is contained in:
ericwyuan
2026-08-20 20:43:50 +08:00
parent 0d5173f442
commit c5c8496409

View File

@@ -275,7 +275,12 @@ class Dispatcher:
self._dispatch_direct(task, payload, upload_path)
def _dispatch_direct(self, task, payload, video_path):
"""小文件直接上传至 /enqueue"""
"""小文件直接上传至 /enqueue
注意 timeout 第一参数: urllib3 发送 multipart body 期间 socket
timeout 取的是 connect timeout 值(实测传 60s 则 60s 整超时),
而非 read timeout——跨境 1.4MB/s 下 17MB 需 ~12s必须给足。
"""
task_id = task['task_id']
try:
with open(video_path, 'rb') as fh:
@@ -283,7 +288,7 @@ class Dispatcher:
self.edge_url,
data=payload,
files={'video': (os.path.basename(video_path), fh, 'video/mp4')},
timeout=(10, 300)
timeout=(120, 300)
)
except requests.RequestException as e:
logger.error(f"[task_id={task_id}] 上传失败: {e}")