Non controllare aggiornamenti videoteca se service deve riavviarsi
This commit is contained in:
28
service.py
28
service.py
@@ -29,6 +29,8 @@ from servers import torrent
|
||||
|
||||
# if this service need to be reloaded because an update changed it
|
||||
needsReload = False
|
||||
# list of threads
|
||||
threads = []
|
||||
|
||||
|
||||
def update(path, p_dialog, i, t, serie, overwrite):
|
||||
@@ -314,6 +316,12 @@ def get_ua_list():
|
||||
def run_threaded(job_func, args):
|
||||
job_thread = threading.Thread(target=job_func, args=args)
|
||||
job_thread.start()
|
||||
threads.append(job_thread)
|
||||
|
||||
|
||||
def join_threads():
|
||||
for th in threads:
|
||||
th.join()
|
||||
|
||||
|
||||
class AddonMonitor(xbmc.Monitor):
|
||||
@@ -327,14 +335,15 @@ class AddonMonitor(xbmc.Monitor):
|
||||
self.scheduleUpdater()
|
||||
self.scheduleUA()
|
||||
|
||||
# videolibrary wait
|
||||
update_wait = [0, 10000, 20000, 30000, 60000]
|
||||
wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))]
|
||||
if wait > 0:
|
||||
xbmc.sleep(wait)
|
||||
if not config.get_setting("update", "videolibrary") == 2:
|
||||
run_threaded(check_for_update, (False,))
|
||||
self.scheduleVideolibrary()
|
||||
if not needsReload: # do not run videolibrary update if service needs to be reloaded
|
||||
# videolibrary wait
|
||||
update_wait = [0, 10000, 20000, 30000, 60000]
|
||||
wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))]
|
||||
if wait > 0:
|
||||
xbmc.sleep(wait)
|
||||
if not config.get_setting("update", "videolibrary") == 2:
|
||||
run_threaded(check_for_update, (False,))
|
||||
self.scheduleVideolibrary()
|
||||
super(AddonMonitor, self).__init__()
|
||||
|
||||
def onSettingsChanged(self):
|
||||
@@ -516,15 +525,18 @@ if __name__ == "__main__":
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
if needsReload:
|
||||
join_threads()
|
||||
db.close()
|
||||
logger.info('Relaunching service.py')
|
||||
xbmc.executeJSONRPC(
|
||||
'{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.kod", "enabled": false }}')
|
||||
xbmc.executeJSONRPC(
|
||||
'{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.kod", "enabled": true }}')
|
||||
logger.debug(threading.enumerate())
|
||||
break
|
||||
|
||||
if monitor.waitForAbort(1): # every second
|
||||
join_threads()
|
||||
# db need to be closed when not used, it will cause freezes
|
||||
db.close()
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user