aboutsummaryrefslogtreecommitdiff
path: root/voctogui
diff options
context:
space:
mode:
authorMaZderMind <github@mazdermind.de>2016-01-06 12:06:25 +0100
committerMaZderMind <github@mazdermind.de>2016-01-06 12:06:25 +0100
commit989f2e715610425c904d4a5ad909987a782bbe33 (patch)
treede810ad196c36a35cc963ee328e2d7b3fa4ac723 /voctogui
parent0520085957a85efef56b266a1d0939709182c7f7 (diff)
port better on_loop scheduling to the gui
Diffstat (limited to 'voctogui')
-rw-r--r--voctogui/lib/connection.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/voctogui/lib/connection.py b/voctogui/lib/connection.py
index 20197d0..bc8b867 100644
--- a/voctogui/lib/connection.py
+++ b/voctogui/lib/connection.py
@@ -48,7 +48,6 @@ def enterNonblockingMode():
log.debug('entering nonblocking-mode')
conn.setblocking(False)
GObject.io_add_watch(conn, GObject.IO_IN, on_data, [''])
- GObject.idle_add(on_loop)
def on_data(conn, _, leftovers, *args):
global log
@@ -80,6 +79,10 @@ def on_data(conn, _, leftovers, *args):
log.debug("got line: %r", line)
line = line.strip()
+ if command_queue.empty():
+ log.debug('command_queue was empty, re-starting on_loop scheduling')
+ GObject.idle_add(on_loop)
+
command_queue.put((line, conn))
if lines[-1] != '':
@@ -89,18 +92,23 @@ def on_data(conn, _, leftovers, *args):
return True
def on_loop():
- global command_queue
-
'''Command handler. Processes commands in the command queue whenever
nothing else is happening (registered as GObject idle callback)'''
+
+ global command_queue
+
+ log.debug('on_loop called')
+
if command_queue.empty():
- return True
+ log.debug('command_queue is empty again, stopping on_loop scheduling')
+ return False
line, requestor = command_queue.get()
words = line.split()
if len(words) < 1:
- return True
+ log.debug('command_queue is empty again, stopping on_loop scheduling')
+ return False
signal = words[0]
args = words[1:]