style: auto-format with black + isort + ruff + prettier [skip ci-format-check]

This commit is contained in:
CI Bot
2026-09-26 10:47:27 +00:00
committed by saas-backend
parent 105ab54059
commit 39c064ba1c
4 changed files with 49 additions and 17 deletions
+17 -6
View File
@@ -12,12 +12,12 @@
任何环节失败抛 GpuEncodeError,调用方应 fallback 到 CPU libx264。
"""
from __future__ import annotations
import json
import logging
import os
import secrets
import socket
import time
import urllib.error
@@ -161,7 +161,10 @@ class GpuEncoderClient:
job = self._post_sync(body, mezzanine_path=mezzanine_path)
logger.info(
"[gpu-encoder] P4000 done: job_id=%s rc=%s size=%s dur=%ss",
job.get("job_id"), job.get("ffmpeg_rc"), job.get("size"), job.get("duration"),
job.get("job_id"),
job.get("ffmpeg_rc"),
job.get("size"),
job.get("duration"),
)
# 5. download result from relay to output_path
@@ -173,7 +176,10 @@ class GpuEncoderClient:
logger.info(
"[gpu-encoder] encode ok: %s → %s (%d bytes) total=%.2fs",
mezzanine_path.name, output_path.name, size, time.time() - t_total,
mezzanine_path.name,
output_path.name,
size,
time.time() - t_total,
)
return {"job": job, "output_size": size, "output_path": str(output_path)}
@@ -214,7 +220,8 @@ class GpuEncoderClient:
req_timeout = body.get("timeout", self.sync_timeout) + 60
payload = json.dumps(body).encode("utf-8")
req = urllib.request.Request(
url, data=payload,
url,
data=payload,
headers={"Content-Type": "application/json"},
method="POST",
)
@@ -267,8 +274,10 @@ class GpuEncoderClient:
return size
except (urllib.error.URLError, socket.timeout, TimeoutError, ConnectionError) as e:
if tmp.exists():
try: tmp.unlink()
except OSError: pass
try:
tmp.unlink()
except OSError:
pass
raise GpuEncodeError(f"failed to download from relay: {e}") from e
def _relay_delete(self, url: str) -> None:
@@ -303,6 +312,7 @@ class GpuEncoderClient:
def _delete_oss(self, key: str) -> None:
try:
from packages.shared.storage import get_storage_service
storage = get_storage_service()
if storage is not None and storage.bucket is not None:
storage.delete_file(key)
@@ -319,6 +329,7 @@ _default_client_initialized: bool = False
def _build_client_from_settings() -> Optional[GpuEncoderClient]:
try:
from packages.config import get_shared_settings
settings = get_shared_settings()
except Exception: # noqa: BLE001
return None