Review item throttle

This commit is contained in:
angelblue05 2016-02-08 18:38:41 -06:00
parent 1e3f590d99
commit 994a48df7e

View file

@ -244,13 +244,15 @@ class Read_EmbyServer():
"MediaSources" "MediaSources"
) )
result = doUtils(url, parameters=params) result = doUtils(url, parameters=params)
try:
if result == "": items['Items'].extend(result['Items'])
# Something happened to the connection. except TypeError:
# Something happened to the connection
if not throttled: if not throttled:
throttled = True throttled = True
self.logMsg("Throttle activated.", 1) self.logMsg("Throttle activated.", 1)
elif jump == highestjump:
if jump == highestjump:
# We already adjusted to highestjump, but it failed. Reset value # We already adjusted to highestjump, but it failed. Reset value
self.logMsg("Reset highest value.", 1) self.logMsg("Reset highest value.", 1)
highestjump = 0 highestjump = 0
@ -259,15 +261,16 @@ class Read_EmbyServer():
if highestjump: if highestjump:
throttled = False throttled = False
jump = highestjump jump = highestjump
self.logMsg("Throttle deactivated.", 1)
else: else:
jump = int(jump/2) jump = int(jump/4)
self.logMsg("Set jump limit to recover: %s" % jump, 1)
self.logMsg("Set jump limit to recover: %s" % jump)
retry = 0 retry = 0
while utils.window('emby_online') != "true": while utils.window('emby_online') != "true":
# Wait server to come back online # Wait server to come back online
if retry == 3: if retry == 3:
self.logMsg("Server never came back online.") self.logMsg("Unable to reconnect to server. Abort process.", 1)
return return
retry += 1 retry += 1
@ -275,9 +278,7 @@ class Read_EmbyServer():
# Abort was requested while waiting. # Abort was requested while waiting.
return return
else: else:
xbmc.Monitor().waitForAbort(3) # Request succeeded
else:
items['Items'].extend(result['Items'])
index += jump index += jump
if dialog: if dialog:
@ -289,17 +290,12 @@ class Read_EmbyServer():
highestjump = jump highestjump = jump
if throttled: if throttled:
# We needed to adjust the number, keep increasing until. # We needed to adjust the number of item requested.
if jump < highestjump:
# Found a number that already works, use it.
throttled = False
jump = highestjump
self.logMsg("Throttle deactivated with jump limit set to: %s" % jump, 1)
else:
# keep increasing until the connection times out again # keep increasing until the connection times out again
# to find the highest value
increment = int(jump*0.33) increment = int(jump*0.33)
if not increment: # Incase the increment is 0 if not increment: # Incase the increment is 0
increment += 10 increment = 10
jump += increment jump += increment
self.logMsg("Increase jump limit to: %s" % jump, 1) self.logMsg("Increase jump limit to: %s" % jump, 1)