summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-12-28 00:21:53 +0100
committeremkael <emkael@tlen.pl>2017-12-28 00:21:53 +0100
commitc58133066ffe7cef126584b84da124634d7f0e99 (patch)
tree6f83987f71770ab93c2e4ca705a3ce36509fa0c0
parent800638c6db23f3468df72cd03d8a04517c90a5f7 (diff)
Logging messages queue improvements
-rw-r--r--src/bidding_data_gui.py12
1 files 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()