lemonbar: Change write queue to Shelf.
Possibly significant performance increase
This commit is contained in:
@@ -11,7 +11,7 @@ kill_on_unfocus = []
|
||||
logger = None
|
||||
health_logger = None
|
||||
|
||||
write_queue = None # TODO Actually, why is this a queue? Just last element is important
|
||||
bar_in_shelf = None
|
||||
|
||||
# TODO bar mode can be moved to i3Module
|
||||
class bar_mode(Enum):
|
||||
|
||||
@@ -107,7 +107,7 @@ def put_fifo_in_queue():
|
||||
common.logger.debug("Writer closed")
|
||||
break
|
||||
data = data.rstrip() # Remove trailing newlines
|
||||
common.write_queue.put(lemonparser.parse_line(data))
|
||||
common.bar_in_shelf.put(lemonparser.parse_line(data))
|
||||
except BrokenPipeError:
|
||||
common.logger.debug('Broken pipe in parse status thread, exiting')
|
||||
common.health_logger.info('Broken pipe in parse status thread, exiting')
|
||||
@@ -124,12 +124,7 @@ def write_parsed():
|
||||
, stdout=subprocess.PIPE, text=True)
|
||||
|
||||
while True:
|
||||
data = common.write_queue.get() # Blocking read
|
||||
if data is None:
|
||||
common.logger.debug('Queue closed')
|
||||
common.health_logger.info('Queue closed')
|
||||
break
|
||||
|
||||
data = common.bar_in_shelf.get() # Blocking read
|
||||
p_lemonbar.stdin.write(data + '\n')
|
||||
p_lemonbar.stdin.flush()
|
||||
#common.logger.debug('Read: "{0}"'.format(data))
|
||||
@@ -216,7 +211,7 @@ if __name__ == "__main__":
|
||||
signal.signal(signal.SIGTERM, handle_exit)
|
||||
signal.signal(signal.SIGINT, handle_exit)
|
||||
|
||||
common.write_queue = queue.Queue()
|
||||
common.bar_in_shelf = common.Shelf()
|
||||
|
||||
# Start writing and reading threads
|
||||
# Create readers before writers
|
||||
|
||||
@@ -42,7 +42,7 @@ class LemonModule(threading.Thread):
|
||||
break
|
||||
|
||||
parsed = self.parse(line)
|
||||
common.write_queue.put(parsed)
|
||||
common.bar_in_shelf.put(parsed)
|
||||
|
||||
def stop(self):
|
||||
self._stop_module()
|
||||
|
||||
Reference in New Issue
Block a user