Smarter, faster way to tell PMS went offline
This commit is contained in:
parent
65ac1b3f00
commit
6b329fbb02
1 changed files with 9 additions and 0 deletions
|
@ -97,6 +97,7 @@ class WebSocket(threading.Thread):
|
||||||
log = self.logMsg
|
log = self.logMsg
|
||||||
log("----===## Starting WebSocketClient ##===----", 0)
|
log("----===## Starting WebSocketClient ##===----", 0)
|
||||||
|
|
||||||
|
counter = 0
|
||||||
threadStopped = self.threadStopped
|
threadStopped = self.threadStopped
|
||||||
threadSuspended = self.threadSuspended
|
threadSuspended = self.threadSuspended
|
||||||
while not threadStopped():
|
while not threadStopped():
|
||||||
|
@ -133,6 +134,12 @@ class WebSocket(threading.Thread):
|
||||||
# Server is probably offline
|
# Server is probably offline
|
||||||
log("Error connecting", 0)
|
log("Error connecting", 0)
|
||||||
self.ws = None
|
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)
|
xbmc.sleep(1000)
|
||||||
except websocket.WebSocketTimeoutException:
|
except websocket.WebSocketTimeoutException:
|
||||||
log("timeout while connecting, trying again", 0)
|
log("timeout while connecting, trying again", 0)
|
||||||
|
@ -142,6 +149,8 @@ class WebSocket(threading.Thread):
|
||||||
log("Unknown exception encountered in connecting: %s" % e)
|
log("Unknown exception encountered in connecting: %s" % e)
|
||||||
self.ws = None
|
self.ws = None
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
|
else:
|
||||||
|
counter = 0
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log("Unknown exception encountered: %s" % e)
|
log("Unknown exception encountered: %s" % e)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue