From 558bd639310af889276e81c050845d37745673e3 Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 16 Nov 2024 23:03:10 -0300 Subject: [PATCH] Fixes the 'read operation timed out' exception. When using the 'comfy model download' command to download large models from Civitai, an exception with the message 'The read operation timed out' is frequently thrown. This change prevents the exception from occurring. --- comfy_cli/file_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/comfy_cli/file_utils.py b/comfy_cli/file_utils.py index 6e6df0f..a9a2ad0 100644 --- a/comfy_cli/file_utils.py +++ b/comfy_cli/file_utils.py @@ -69,7 +69,9 @@ def download_file(url: str, local_filepath: pathlib.Path, headers: Optional[dict """Helper function to download a file.""" local_filepath.parent.mkdir(parents=True, exist_ok=True) # Ensure the directory exists - with httpx.stream("GET", url, follow_redirects=True, headers=headers) as response: + timeout = httpx.Timeout(timeout=5.0, read=None) # Default timeout with no read timeout + + with httpx.stream("GET", url, follow_redirects=True, headers=headers, timeout=timeout) as response: if response.status_code == 200: total = int(response.headers["Content-Length"]) try: