Skip to content

Commit e3a070d

Browse files
authored
fix(toolkit): retry on URLError (#593)
* fix(toolkit): retry on URLError * Update projects/fal/src/fal/toolkit/file/providers/fal.py * Update projects/fal/src/fal/toolkit/file/providers/fal.py
1 parent 069dec9 commit e3a070d

File tree

1 file changed

+6
-1
lines changed
  • projects/fal/src/fal/toolkit/file/providers

1 file changed

+6
-1
lines changed

projects/fal/src/fal/toolkit/file/providers/fal.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from datetime import datetime, timezone
1111
from pathlib import Path
1212
from typing import Any, Dict, Generator, Generic, TypeVar
13-
from urllib.error import HTTPError
13+
from urllib.error import HTTPError, URLError
1414
from urllib.parse import urlparse, urlunparse
1515
from urllib.request import Request, urlopen
1616
from urllib.response import addinfourl
@@ -44,6 +44,11 @@ def _urlopen(
4444
def _should_retry(exc: Exception) -> bool:
4545
if isinstance(exc, HTTPError) and exc.code in RETRY_CODES:
4646
return True
47+
elif type(exc) is URLError:
48+
# URLError is a base class for other errors,
49+
# but it can be raised directly, e.g.
50+
# URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
51+
return True
4752

4853
if isinstance(exc, TimeoutError):
4954
return True

0 commit comments

Comments
 (0)