From 7061df44a9f2291c9a9147dea6878bbc1bd424d8 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 15 Nov 2015 18:38:06 +0100 Subject: Exit the Mainloop (and End the Program) when the Control-Connection dies, fixes #21 --- voctogui/lib/connection.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'voctogui/lib/connection.py') diff --git a/voctogui/lib/connection.py b/voctogui/lib/connection.py index 6bece3d..20197d0 100644 --- a/voctogui/lib/connection.py +++ b/voctogui/lib/connection.py @@ -4,7 +4,7 @@ import socket import json import sys from queue import Queue -from gi.repository import GObject +from gi.repository import Gtk, GObject log = logging.getLogger('Connection') conn = None @@ -60,10 +60,12 @@ def on_data(conn, _, leftovers, *args): try: leftovers.append(conn.recv(4096).decode(errors='replace')) if len(leftovers[-1]) == 0: - log.info("socket was closed") + log.info("Socket was closed") # FIXME try to reconnect - sys.exit(1) + conn.close() + Gtk.main_quit() + return False except UnicodeDecodeError as e: continue -- cgit v1.2.3