Mercurial > public > sg101
comparison gpp/antispam/rate_limit.py @ 578:a18516692273
Correct my Redis API error in unit test.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 May 2012 14:49:42 -0500 |
parents | 6a265b5768ca |
children |
comparison
equal
deleted
inserted
replaced
577:4fb264b671d5 | 578:a18516692273 |
---|---|
60 """ | 60 """ |
61 key = _make_key(ip) | 61 key = _make_key(ip) |
62 conn = _get_connection() | 62 conn = _get_connection() |
63 | 63 |
64 try: | 64 try: |
65 conn.setex(key, count, _to_seconds(interval)) | 65 conn.setex(key, time=_to_seconds(interval), value=count) |
66 except redis.RedisError, e: | 66 except redis.RedisError, e: |
67 logger.error("rate limit (block_ip): %s" % e) | 67 logger.error("rate limit (block_ip): %s" % e) |
68 raise RateLimiterUnavailable | 68 raise RateLimiterUnavailable |
69 | 69 |
70 logger.info("Rate limiter blocked IP %s; %d / %s", ip, count, interval) | 70 logger.info("Rate limiter blocked IP %s; %d / %s", ip, count, interval) |