diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2013-03-15 19:03:07 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2013-03-15 19:03:07 +0100 |
| commit | 94bc6d99501ceb4521273736e89b6572c527424c (patch) | |
| tree | 7ad5353c0e31a0c83a4e0a8f63b79b003cb8d6b7 | |
| parent | faf28672e18121804d40e315a1406b97f80e3145 (diff) | |
dont fail if i3status output comes slower than py3status message polling interval
| -rw-r--r-- | py3status/__init__.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/py3status/__init__.py b/py3status/__init__.py index 6fea1b2..6d21a41 100644 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -42,6 +42,7 @@ from datetime import timedelta from syslog import syslog from syslog import LOG_ERR +from syslog import LOG_INFO try: # python3 @@ -239,12 +240,13 @@ def main(): # globals CACHE_TIMEOUT = OPTS.cache_timeout + DELTA = 0 DISABLE_TRANSFORM = True if OPTS.disable_transform else False I3STATUS_CONFIG_FILE = OPTS.i3status_conf I3STATUS_CONFIG = i3status_config_reader() INCLUDE_PATH = os.path.abspath( OPTS.include_path ) + '/' INTERVAL = OPTS.interval - DELTA = 0 + STARTED = False # py3status uses only the i3bar protocol assert I3STATUS_CONFIG['output_format'] == 'i3bar', 'unsupported output_format' @@ -278,13 +280,17 @@ def main(): pass if LINE.startswith(',['): sleep( INTERVAL - float( '{:.2}'.format( time()-TS ) ) ) + STARTED = True process_line(LINE, delta=0) DELTA = 0 except Empty: - DELTA += INTERVAL - process_line(LINE, delta=DELTA) - if threading.active_count() < 2: - break + if STARTED: + DELTA += INTERVAL + process_line(LINE, delta=DELTA) + if threading.active_count() < 2: + break + else: + syslog(LOG_INFO, "py3status waiting for i3status") except KeyboardInterrupt: break |
