diff --git a/backend/app/services/gallery_dl.py b/backend/app/services/gallery_dl.py index e149477..2883bd4 100644 --- a/backend/app/services/gallery_dl.py +++ b/backend/app/services/gallery_dl.py @@ -42,6 +42,15 @@ class ErrorType(StrEnum): UNKNOWN_ERROR = "unknown_error" +# Pinned to download_source's Celery soft_time_limit (900s, see +# tasks/download.py:32). Anything larger and Celery kills the task before +# subprocess.run can raise TimeoutExpired — leaving the DownloadEvent +# stranded for the recovery sweep instead of capturing a clean timeout +# error. Per-source bumps live in source.config_overrides for legitimately +# long syncs. Operator-confirmed 2026-05-30 (~40-min hang investigation). +_DEFAULT_GDL_TIMEOUT_SECONDS = 900 + + @dataclass class SourceConfig: content_types: list[str] = field(default_factory=lambda: ["all"]) @@ -51,7 +60,7 @@ class SourceConfig: filename_pattern: str | None = None skip_existing: bool = True save_metadata: bool = True - timeout: int = 3600 + timeout: int = _DEFAULT_GDL_TIMEOUT_SECONDS @classmethod def from_dict(cls, data: dict) -> SourceConfig: @@ -63,7 +72,7 @@ class SourceConfig: filename_pattern=data.get("filename_pattern"), skip_existing=data.get("skip_existing", True), save_metadata=data.get("save_metadata", True), - timeout=data.get("timeout", 3600), + timeout=data.get("timeout", _DEFAULT_GDL_TIMEOUT_SECONDS), )