From 41e92e277e6eb9846d1ac21d95b8fc16099cdcca Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Wed, 17 Feb 2016 21:17:38 +0800 Subject: [PATCH] fix iter.next ? --- shadowsocks/lru_cache.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shadowsocks/lru_cache.py b/shadowsocks/lru_cache.py index e50d0b5..32bab66 100644 --- a/shadowsocks/lru_cache.py +++ b/shadowsocks/lru_cache.py @@ -82,7 +82,8 @@ class LRUCache(collections.MutableMapping): def first(self): if len(self._keys_to_last_time) > 0: - return iter(self._keys_to_last_time).next() + for key in self._keys_to_last_time: + return key def sweep(self): # O(n - m) @@ -91,7 +92,8 @@ class LRUCache(collections.MutableMapping): while c < SWEEP_MAX_ITEMS: if len(self._keys_to_last_time) == 0: break - key = iter(self._keys_to_last_time).next() + for key in self._keys_to_last_time: + break last_t = self._keys_to_last_time[key] if now - last_t <= self.timeout: break