mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-05-06 16:36:45 -03:00
Merge pull request #906 from willmiao/codex/github-mention-fixnetwork-add-connectivityguard-to-short
fix(network): return friendly offline message for memory downloads
This commit is contained in:
@@ -23,6 +23,7 @@ from typing import Optional, Dict, Tuple, Callable, Union, Awaitable
|
|||||||
from ..services.settings_manager import get_settings_manager
|
from ..services.settings_manager import get_settings_manager
|
||||||
from .connectivity_guard import (
|
from .connectivity_guard import (
|
||||||
OFFLINE_COOLDOWN_ERROR,
|
OFFLINE_COOLDOWN_ERROR,
|
||||||
|
OFFLINE_FRIENDLY_MESSAGE,
|
||||||
ConnectivityGuard,
|
ConnectivityGuard,
|
||||||
)
|
)
|
||||||
from .errors import RateLimitError
|
from .errors import RateLimitError
|
||||||
@@ -803,9 +804,8 @@ class Downloader:
|
|||||||
Tuple[bool, Union[bytes, str], Optional[Dict]]: (success, content or error message, response headers if requested)
|
Tuple[bool, Union[bytes, str], Optional[Dict]]: (success, content or error message, response headers if requested)
|
||||||
"""
|
"""
|
||||||
guard = await ConnectivityGuard.get_instance()
|
guard = await ConnectivityGuard.get_instance()
|
||||||
destination = self._guard_destination(url)
|
if guard.should_block_request():
|
||||||
if guard.should_block_request(destination):
|
return False, OFFLINE_FRIENDLY_MESSAGE, None
|
||||||
return False, OFFLINE_COOLDOWN_ERROR, None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
session = await self.session
|
session = await self.session
|
||||||
@@ -849,9 +849,9 @@ class Downloader:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if guard.is_network_unreachable_error(e):
|
if guard.is_network_unreachable_error(e):
|
||||||
guard.register_network_failure(e, destination)
|
guard.register_network_failure(e)
|
||||||
if guard.should_block_request(destination):
|
if guard.should_block_request():
|
||||||
return False, OFFLINE_COOLDOWN_ERROR, None
|
return False, OFFLINE_FRIENDLY_MESSAGE, None
|
||||||
logger.debug("Network unavailable during memory download: %s", e)
|
logger.debug("Network unavailable during memory download: %s", e)
|
||||||
return False, str(e), None
|
return False, str(e), None
|
||||||
logger.error(f"Error downloading to memory from {url}: {e}")
|
logger.error(f"Error downloading to memory from {url}: {e}")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import pytest
|
|||||||
|
|
||||||
from py.services.connectivity_guard import (
|
from py.services.connectivity_guard import (
|
||||||
OFFLINE_COOLDOWN_ERROR,
|
OFFLINE_COOLDOWN_ERROR,
|
||||||
|
OFFLINE_FRIENDLY_MESSAGE,
|
||||||
ConnectivityGuard,
|
ConnectivityGuard,
|
||||||
)
|
)
|
||||||
from py.services.downloader import Downloader
|
from py.services.downloader import Downloader
|
||||||
@@ -93,7 +94,7 @@ async def test_downloader_short_circuits_all_request_helpers_during_cooldown():
|
|||||||
|
|
||||||
ok, payload, headers = await downloader.download_to_memory(f"https://{destination}")
|
ok, payload, headers = await downloader.download_to_memory(f"https://{destination}")
|
||||||
assert ok is False
|
assert ok is False
|
||||||
assert payload == OFFLINE_COOLDOWN_ERROR
|
assert payload == OFFLINE_FRIENDLY_MESSAGE
|
||||||
assert headers is None
|
assert headers is None
|
||||||
|
|
||||||
ok, payload = await downloader.get_response_headers(f"https://{destination}")
|
ok, payload = await downloader.get_response_headers(f"https://{destination}")
|
||||||
|
|||||||
Reference in New Issue
Block a user