Skip to content

Commit e988f2a

Browse files
authored
Merge pull request #6895 from readthedocs/humitos/azure-blob-timeout
On Azure .exists blob timeout, log the exception and return False
2 parents 5d8a969 + 9ffd97f commit e988f2a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

readthedocs/storage/azure_storage.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Django storage classes to use with Azure Blob storage service."""
55

6+
import logging
67
from azure.common import AzureMissingResourceHttpError
78
from django.conf import settings
89
from django.contrib.staticfiles.storage import ManifestFilesMixin
@@ -13,6 +14,9 @@
1314
from .mixins import OverrideHostnameMixin
1415

1516

17+
log = logging.getLogger(__name__) # pylint: disable=invalid-name
18+
19+
1620
class AzureBuildMediaStorage(BuildMediaStorageMixin, OverrideHostnameMixin, AzureStorage):
1721

1822
"""An Azure Storage backend for build artifacts."""
@@ -30,6 +34,14 @@ def url(self, name, expire=None, http_method=None): # noqa
3034
"""
3135
return super().url(name, expire)
3236

37+
def exists(self, name):
38+
"""Override to catch timeout exception and return False."""
39+
try:
40+
return super().exists(name)
41+
except Exception: # pylint: disable=broad-except
42+
log.exception('Timeout calling Azure .exists. name=%s', name)
43+
return False
44+
3345

3446
class AzureBuildStorage(AzureStorage):
3547

0 commit comments

Comments
 (0)