From c58133066ffe7cef126584b84da124634d7f0e99 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 28 Dec 2017 00:21:53 +0100 Subject: Logging messages queue improvements --- src/bidding_data_gui.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bidding_data_gui.py b/src/bidding_data_gui.py index fd07a7d..c41504e 100644 --- a/src/bidding_data_gui.py +++ b/src/bidding_data_gui.py @@ -15,6 +15,7 @@ import Queue import socket import sys import threading +import time import tkFileDialog import tkMessageBox @@ -520,6 +521,7 @@ class BiddingGUI(tk.Frame): self.__messages_mutex = Lock() self.__messages = [] self.__messages_to_output = [] + self.__message_loop = False self.text.master.queue(self.__output) def emit(self, record): @@ -541,14 +543,17 @@ class BiddingGUI(tk.Frame): self.__messages_mutex.acquire() self.__messages_to_output = copy.copy(self.__messages) self.__messages = [] - self.__messages_mutex.release() if len(self.__messages_to_output) > 0: msg = '\n'.join(self.__messages_to_output).encode('utf8') # Append message to the Text widget, at the end.""" self.text.master.queue(self.text.insert, tk.END, msg + '\n') # scroll to the bottom, afterwards self.text.master.queue(self.text.yview, tk.END) - self.text.master.queue(self.__output) + else: + time.sleep(0.05) + self.__messages_mutex.release() + if self.__message_loop: + self.text.master.queue(self.__output) # message stats, for summary purposes __warning_count = 0 @@ -567,10 +572,12 @@ class BiddingGUI(tk.Frame): self.__messages_mutex.acquire() self.__messages_to_output = [] self.__messages = [] + self.__message_loop = True self.__messages_mutex.release() self.__warning_count = 0 self.__error_count = 0 self.text.master.queue(self.text.delete, 1.0, tk.END) + self.text.master.queue(self.__output) def print_summary(self): self.__messages_mutex.acquire() @@ -593,6 +600,7 @@ class BiddingGUI(tk.Frame): self.__messages.append(self.text.insert, tk.END, 'Wszystko wporzo.\n') self.text.master.queue(res.play, 'success') + self.__message_loop = False self.__messages_mutex.release() -- cgit v1.2.3