Commits

Goodbed Robot committed 6801690 Draft

email debug messages, highly product-specific

Comments (0)

Files changed (1)

cache_utils/decorators.py

 
             # try to get the value from cache
             key = get_key(wrapper._full_name, func_type, n_args, n_kwargs)
-            value = cache.get(key, **backend_kwargs)
+
+            try:
+                value = cache.get(key, **backend_kwargs)
+            except:
+                from django.core.mail import send_mail
+                from django.contrib.gis.geos import Point
+                import traceback
+                msg = traceback.format_exc()
+                msg += "\nkey: "+key
+                if n_args and isinstance(n_args[0], Point):
+                    msg += "\npoint: "+n_args[0].json
+                send_mail('Caching fail', msg, ' info@goodbed.com', ['admin@goodbed.com'], fail_silently=False)
 
             # in case of cache miss recalculate the value and put it to the cache
             if value is None:
                 value = func(*args, **kwargs)
-                cache.set(key, value, timeout, **backend_kwargs)
+                try:
+                    cache.set(key, value, timeout, **backend_kwargs)
+                except:
+                    from django.core.mail import send_mail
+                    from django.contrib.gis.geos import Point
+                    import traceback
+                    msg = traceback.format_exc()
+                    msg += "\nkey: "+key
+                    if n_args and isinstance(n_args[0], Point):
+                        msg += "\npoint: "+n_args[0].json
+                    send_mail('Caching fail', msg, ' info@goodbed.com', ['admin@goodbed.com'], fail_silently=False)
+
             return value
 
         def invalidate(*args, **kwargs):