Skip to content

Commit

Permalink
On Azure .exists blob timeout, log the exception and return False
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Apr 13, 2020
1 parent 5b605e4 commit a71b446
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions readthedocs/storage/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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

import logging
from azure.common import AzureMissingResourceHttpError
from django.conf import settings
from django.contrib.staticfiles.storage import ManifestFilesMixin
Expand All @@ -13,6 +14,9 @@
from .mixins import OverrideHostnameMixin


log = logging.getLogger(__name__)


class AzureBuildMediaStorage(BuildMediaStorageMixin, OverrideHostnameMixin, AzureStorage):

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

def exists(self, name, timeout=None):
"""Override to catch timeout exception and return False."""
try:
exists = super().exists(name)
except:
log.exception('Timeout calling Azure .exists. name=%s', name)
return False


class AzureBuildStorage(AzureStorage):

Expand Down

0 comments on commit a71b446

Please sign in to comment.