diff --git a/avatars/avatars.py b/avatars/avatars.py
index 220cae9cb..eaf58bc52 100644
--- a/avatars/avatars.py
+++ b/avatars/avatars.py
@@ -1,5 +1,10 @@
import hashlib
import math
+import logging
+
+from requests.exceptions import RequestException
+
+logger = logging.getLogger(__name__)
class Avatar(object):
def __init__(self, app=None):
@@ -32,10 +37,13 @@ class BaseAvatar(object):
if url is not None:
# Try to load the gravatar. If we get a non-404 response, then we use it in place of
# the CSS avatar.
- response = self.http_client.get(url)
- if response.status_code == 200:
- return """""" % (url, size, size, kind)
+ try:
+ response = self.http_client.get(url, timeout=5)
+ if response.status_code == 200:
+ return """""" % (url, size, size, kind)
+ except RequestException:
+ logger.exception('Could not retrieve avatar for user %s', name)
radius = '50%' if kind == 'team' else '0%'
letter = 'Ω' if kind == 'team' and data['name'] == 'owners' else data['name'].upper()[0]