Trees | Indices | Help |
|
---|
|
1 ########################################################################### 2 # 3 # This program is part of Zenoss Core, an open source monitoring platform. 4 # Copyright (C) 2007, Zenoss Inc. 5 # 6 # This program is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 as published by 8 # the Free Software Foundation. 9 # 10 # For complete information please visit: http://www.zenoss.com/oss/ 11 # 12 ########################################################################### 13 14 import threading 15 import time 1618 "Store elements in a map for the given time" 19 24 2568 69 10527 "remove old values" 28 # FIXME O(N) search 29 if now is None: 30 now = time.time() 31 if self.lastClean + self.timeout > now: 32 return 33 for k, (v, t) in self.map.items(): 34 if t + self.timeout < now: 35 del self.map[k] 36 self.lastClean = now37 3840 now = time.time() 41 self.clean(now) 42 v, t = self.map.get(key, (default, None) ) 43 if t is None or t + self.timeout < now: 44 return default 45 return v46 4749 now = time.time() 50 v, t = self.map[key] 51 if t + self.timeout < now: 52 del self.map[key] 53 raise KeyError 54 return v55 56 61 62
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:25 2007 | http://epydoc.sourceforge.net |