From 3eaeaf2082d163c22a72f824641e2d1c06c4a9d8 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Fri, 22 Feb 2013 12:34:50 +0100 Subject: user can implement his own cache timeout on his module response --- py3status/py3status.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'py3status') diff --git a/py3status/py3status.py b/py3status/py3status.py index d89a7d5..8c22fff 100755 --- a/py3status/py3status.py +++ b/py3status/py3status.py @@ -140,9 +140,15 @@ def inject(j): if time() > result['cached_until']: raise KeyError, 'cache timeout' except KeyError: + # execute the method meth = getattr(my_class, my_method) index, result = meth(j) - result['cached_until'] = time() + CACHE_TIMEOUT + + # respect user-defined cache timeout for this module + if not result.has_key('cached_until'): + result['cached_until'] = time() + CACHE_TIMEOUT + + # validate the response assert isinstance(result, dict), "user method didn't return a dict" assert result.has_key('full_text'), "missing 'full_text' key" assert result.has_key('name'), "missing 'name' key" -- cgit v1.3