diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2013-02-22 12:34:50 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2013-02-22 12:34:50 +0100 |
| commit | 3eaeaf2082d163c22a72f824641e2d1c06c4a9d8 (patch) | |
| tree | a8306d96a5483472662327d4328347a469bbb863 /py3status/py3status.py | |
| parent | 6ae05c082828c7c819b9413ff80ee8e106272d13 (diff) | |
user can implement his own cache timeout on his module response
Diffstat (limited to 'py3status/py3status.py')
| -rwxr-xr-x | py3status/py3status.py | 8 |
1 files changed, 7 insertions, 1 deletions
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" |
