mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-10-03 00:35:32 -03:00
On a CivitAI/CivArchive 429, download-model and download-model-get now
return HTTP 429 with {"reason": "rate_limited", "retry_after": N}
instead of a generic 500 string, and the queue row goes back to
"queued" rather than history as failed — so queue drivers can
auto-pause and retry later instead of burning through the queue.
- new DownloadRateLimitError carrying retry_after/host (opt-in via
raise_on_rate_limit on Downloader; other call sites keep the legacy
string behavior)
- fail-fast pre-flight gate in DownloadManager consults
RateLimitCoordinator before acquiring the semaphore slot: hosts in
cooldown get an immediate structured 429, no HTTP request attempted
- best-effort 429 detection for the aria2 backend
65 lines
1.6 KiB
Python
65 lines
1.6 KiB
Python
"""Common service-level exception types."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
|
|
class RateLimitError(RuntimeError):
|
|
"""Raised when a remote provider rejects a request due to rate limiting."""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str,
|
|
*,
|
|
retry_after: Optional[float] = None,
|
|
provider: Optional[str] = None,
|
|
) -> None:
|
|
super().__init__(message)
|
|
self.retry_after = retry_after
|
|
self.provider = provider
|
|
|
|
|
|
class DownloadRateLimitError(RateLimitError):
|
|
"""Raised when a file download is rejected with HTTP 429.
|
|
|
|
Carries the vendor's ``Retry-After`` hint (when present) and the target
|
|
host so the download manager can build the structured rate-limit result
|
|
the download queue contract expects.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str,
|
|
*,
|
|
retry_after: Optional[float] = None,
|
|
host: Optional[str] = None,
|
|
) -> None:
|
|
super().__init__(message, retry_after=retry_after)
|
|
self.host = host
|
|
|
|
|
|
class ResourceNotFoundError(RuntimeError):
|
|
"""Raised when a remote resource is permanently missing."""
|
|
|
|
pass
|
|
|
|
|
|
class LLMNotConfiguredError(RuntimeError):
|
|
"""Raised when an LLM-dependent operation is attempted but no provider is configured."""
|
|
|
|
pass
|
|
|
|
|
|
class LLMRateLimitError(RateLimitError):
|
|
"""Raised when the LLM provider rejects a request due to rate limiting."""
|
|
|
|
pass
|
|
|
|
|
|
class LLMResponseError(RuntimeError):
|
|
"""Raised when the LLM returns an unparseable or schema-invalid response."""
|
|
|
|
pass
|
|
|