summaryrefslogtreecommitdiffstats
path: root/py3status
diff options
context:
space:
mode:
authorUltrabug <ultrabug@gentoo.org>2015-01-04 18:22:19 +0100
committerUltrabug <ultrabug@gentoo.org>2015-01-04 18:22:19 +0100
commitb0c36785e0ed59a3dba04991e8a72a4a9f1ba1ca (patch)
tree97031de6176849a3dd3b0a4f096ecd0809ef4e9f /py3status
parent177edbe8038b4bda04a102d6cb34a359cf4ed86d (diff)
rate limit the refresh_all command
Diffstat (limited to 'py3status')
-rwxr-xr-xpy3status/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/py3status/__init__.py b/py3status/__init__.py
index f9b8c19..096ab69 100755
--- a/py3status/__init__.py
+++ b/py3status/__init__.py
@@ -471,6 +471,7 @@ class Events(Thread):
Thread.__init__(self)
self.config = config
self.i3s_config = i3s_config
+ self.last_refresh_ts = time()
self.lock = lock
self.modules = modules
self.on_click = i3s_config['on_click']
@@ -518,13 +519,16 @@ class Events(Thread):
for obj in module.methods.values():
obj['cached_until'] = time()
- @staticmethod
- def refresh_all(module_name):
+ def refresh_all(self, module_name):
"""
Force a full refresh of py3status and i3status modules by sending
a SIGUSR1 signal to py3status.
+
+ We rate limit this command to 1/s for obvious abusive behavior.
"""
- Popen(['killall', '-USR1', 'py3status'])
+ if time() > (self.last_refresh_ts + 1):
+ call(['killall', '-s', 'USR1', '__init__.py'])
+ self.last_refresh_ts = time()
def on_click_dispatcher(self, module_name, command):
"""