Created
December 5, 2016 20:58
-
-
Save dsully/44ec800f09fbb71bd9a1f9a7df293283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConnectionRefusedCacheControlAdapter(CacheControlAdapter): | |
def send(self, request, **kw): | |
try: | |
resp = super(ConnectionRefusedCacheControlAdapter, self).send(request, **kw) | |
except Exception as e: | |
cache_url = self.controller.cache_url(request.url) | |
cache_data = self.controller.cache.get(cache_url) | |
cached_response = self.controller.serializer.loads(request, cache_data) | |
return self.build_response(request, cached_response, from_cache=True) | |
return resp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment