From 6b329fbb024cf4f713390ecb4ed5f7656cc68662 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 29 May 2016 18:51:09 +0200 Subject: [PATCH] Smarter, faster way to tell PMS went offline --- resources/lib/websocket_client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/lib/websocket_client.py b/resources/lib/websocket_client.py index 542822b6..2ea0999a 100644 --- a/resources/lib/websocket_client.py +++ b/resources/lib/websocket_client.py @@ -97,6 +97,7 @@ class WebSocket(threading.Thread): log = self.logMsg log("----===## Starting WebSocketClient ##===----", 0) + counter = 0 threadStopped = self.threadStopped threadSuspended = self.threadSuspended while not threadStopped(): @@ -133,6 +134,12 @@ class WebSocket(threading.Thread): # Server is probably offline log("Error connecting", 0) self.ws = None + counter += 1 + if counter > 10: + log("Repeatedly could not connect to PMS, declaring " + "the connection dead", -1) + utils.window('emby_online', value='false') + counter = 0 xbmc.sleep(1000) except websocket.WebSocketTimeoutException: log("timeout while connecting, trying again", 0) @@ -142,6 +149,8 @@ class WebSocket(threading.Thread): log("Unknown exception encountered in connecting: %s" % e) self.ws = None xbmc.sleep(1000) + else: + counter = 0 except Exception as e: log("Unknown exception encountered: %s" % e) try: