re-introduce commit 1c92c333ad668b173ba5abba552464ffaf990fe7
[plcapi.git] / aspects / ratelimitaspects.py
index e95764f..5aeaa86 100644 (file)
@@ -123,8 +123,11 @@ Subject: %(subject)s
         keys_to_check = ["%s_%s_%s_%s" % (self.prefix, api_method_caller, api_method_source[0], (now - timedelta(minutes = minute)).strftime("%Y%m%d%H%M")) for minute in range(self.minutes + 1)]
 
         try:
-            mc.incr(current_key)
+            value = mc.incr(current_key)
         except ValueError:
+            value = None
+
+        if value == None:
             mc.set(current_key, 1, time=self.expire_after)
 
         results = mc.get_multi(keys_to_check)