lemonbar: Change write queue to Shelf.

Possibly significant performance increase
This commit is contained in:
kuben
2020-01-06 23:13:58 +01:00
committed by Jakub Fojt
parent a57aa206aa
commit c63af798fe
3 changed files with 5 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ kill_on_unfocus = []
logger = None logger = None
health_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 # TODO bar mode can be moved to i3Module
class bar_mode(Enum): class bar_mode(Enum):

View File

@@ -107,7 +107,7 @@ def put_fifo_in_queue():
common.logger.debug("Writer closed") common.logger.debug("Writer closed")
break break
data = data.rstrip() # Remove trailing newlines 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: except BrokenPipeError:
common.logger.debug('Broken pipe in parse status thread, exiting') common.logger.debug('Broken pipe in parse status thread, exiting')
common.health_logger.info('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) , stdout=subprocess.PIPE, text=True)
while True: while True:
data = common.write_queue.get() # Blocking read data = common.bar_in_shelf.get() # Blocking read
if data is None:
common.logger.debug('Queue closed')
common.health_logger.info('Queue closed')
break
p_lemonbar.stdin.write(data + '\n') p_lemonbar.stdin.write(data + '\n')
p_lemonbar.stdin.flush() p_lemonbar.stdin.flush()
#common.logger.debug('Read: "{0}"'.format(data)) #common.logger.debug('Read: "{0}"'.format(data))
@@ -216,7 +211,7 @@ if __name__ == "__main__":
signal.signal(signal.SIGTERM, handle_exit) signal.signal(signal.SIGTERM, handle_exit)
signal.signal(signal.SIGINT, handle_exit) signal.signal(signal.SIGINT, handle_exit)
common.write_queue = queue.Queue() common.bar_in_shelf = common.Shelf()
# Start writing and reading threads # Start writing and reading threads
# Create readers before writers # Create readers before writers

View File

@@ -42,7 +42,7 @@ class LemonModule(threading.Thread):
break break
parsed = self.parse(line) parsed = self.parse(line)
common.write_queue.put(parsed) common.bar_in_shelf.put(parsed)
def stop(self): def stop(self):
self._stop_module() self._stop_module()