mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
Fix slowness
This commit is contained in:
parent
0dd54b019d
commit
026095722c
2 changed files with 22 additions and 17 deletions
|
@ -7,13 +7,14 @@ import logging
|
||||||
import Queue
|
import Queue
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
from libraries import requests
|
from libraries import requests
|
||||||
from helper.utils import should_stop, delete_folder
|
from helper.utils import should_stop, delete_folder
|
||||||
from helper import settings, stop, event, window, kodi_version, unzip
|
from helper import settings, stop, event, window, kodi_version, unzip, create_id
|
||||||
from emby import Emby
|
from emby import Emby
|
||||||
from emby.core import api
|
from emby.core import api
|
||||||
from emby.core.exceptions import HTTPException
|
from emby.core.exceptions import HTTPException
|
||||||
|
@ -268,7 +269,7 @@ class GetItemWorker(threading.Thread):
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
item_id = self.queue.get(timeout=1)
|
item_ids = self.queue.get(timeout=1)
|
||||||
except Queue.Empty:
|
except Queue.Empty:
|
||||||
|
|
||||||
self.is_done = True
|
self.is_done = True
|
||||||
|
@ -276,18 +277,16 @@ class GetItemWorker(threading.Thread):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
request = {'type': "GET", 'handler': "Users/{UserId}/Items/%s" % item_id}
|
|
||||||
try:
|
try:
|
||||||
result = self.server['http/request'](request, s)
|
result = self.server['api'].get_items(item_ids)
|
||||||
|
|
||||||
if result['Type'] in self.output:
|
for item in result['Items']:
|
||||||
self.output[result['Type']].put(result)
|
|
||||||
|
if item['Type'] in self.output:
|
||||||
|
self.output[item['Type']].put(item)
|
||||||
except HTTPException as error:
|
except HTTPException as error:
|
||||||
LOG.error("--[ http status: %s ]", error.status)
|
LOG.error("--[ http status: %s ]", error.status)
|
||||||
|
|
||||||
if error.status != 500: # to retry
|
|
||||||
continue
|
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
|
|
||||||
|
@ -300,22 +299,25 @@ class TheVoid(object):
|
||||||
|
|
||||||
def __init__(self, method, data):
|
def __init__(self, method, data):
|
||||||
|
|
||||||
''' This will block until response is received.
|
''' If you call get, this will block until response is received.
|
||||||
This is meant to go as fast as possible, a response will always be returned.
|
This is used to communicate between entrypoints.
|
||||||
'''
|
'''
|
||||||
if type(data) != dict:
|
if type(data) != dict:
|
||||||
raise Exception("unexpected data format")
|
raise Exception("unexpected data format")
|
||||||
|
|
||||||
data['VoidName'] = id(self)
|
data['VoidName'] = str(create_id())
|
||||||
LOG.info("---[ contact mothership/%s ]", method)
|
LOG.info("---[ contact mothership/%s ]", method)
|
||||||
LOG.debug(data)
|
LOG.debug(data)
|
||||||
|
|
||||||
event(method, data)
|
event(method, data)
|
||||||
self.method = method
|
self.method = method
|
||||||
self.data = data
|
self.data = data
|
||||||
self.monitor = xbmc.Monitor()
|
|
||||||
|
|
||||||
def get(self):
|
def get(self, timeout=None, default=None):
|
||||||
|
|
||||||
|
''' Timeout in seconds, if exceeded will return the default value.
|
||||||
|
'''
|
||||||
|
last_progress = datetime.today()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
@ -328,10 +330,12 @@ class TheVoid(object):
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if window('emby_should_stop.bool') or self.monitor.waitForAbort(0.1):
|
if window('emby_should_stop.bool') or timeout and (datetime.today() - last_progress).seconds > timeout:
|
||||||
LOG.info("Abandon mission! A black hole just swallowed [ %s ]", self.data['VoidName'])
|
LOG.info("Abandon mission! A black hole just swallowed [ %s/%s ]", self.method, self.data['VoidName'])
|
||||||
|
|
||||||
break
|
return default
|
||||||
|
|
||||||
|
xbmc.sleep(10)
|
||||||
|
|
||||||
def get_objects(src, filename):
|
def get_objects(src, filename):
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ from utils import indent
|
||||||
from utils import write_xml
|
from utils import write_xml
|
||||||
from utils import compare_version
|
from utils import compare_version
|
||||||
from utils import unzip
|
from utils import unzip
|
||||||
|
from utils import create_id
|
||||||
|
|
||||||
from wrapper import progress
|
from wrapper import progress
|
||||||
from wrapper import catch
|
from wrapper import catch
|
||||||
|
|
Loading…
Reference in a new issue