From da671c8ee53e4f7080a1816cd6f305ac647a601f Mon Sep 17 00:00:00 2001 From: croneter Date: Tue, 9 Jun 2020 09:37:18 +0200 Subject: [PATCH] Do not instantiate xbmc.Monitor() if possible (guess this leads to issues if we should shut down) --- resources/lib/app/application.py | 4 ++-- resources/lib/backgroundthread.py | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/resources/lib/app/application.py b/resources/lib/app/application.py index 364345d2..79608afd 100644 --- a/resources/lib/app/application.py +++ b/resources/lib/app/application.py @@ -134,7 +134,7 @@ class App(object): thread.suspend(block=True) else: break - return xbmc.Monitor().abortRequested() + return self.monitor.abortRequested() def resume_threads(self): """ @@ -144,7 +144,7 @@ class App(object): LOG.debug('Resuming threads: %s', self.threads) for thread in self.threads: thread.resume() - return xbmc.Monitor().abortRequested() + return self.monitor.abortRequested() def stop_threads(self, block=True): """ diff --git a/resources/lib/backgroundthread.py b/resources/lib/backgroundthread.py index 77a068fe..831b3274 100644 --- a/resources/lib/backgroundthread.py +++ b/resources/lib/backgroundthread.py @@ -8,8 +8,6 @@ import Queue import heapq from collections import deque -import xbmc - from . import utils, app, variables as v WORKER_COUNT = 3 @@ -305,7 +303,7 @@ class Task(object): self._canceled = True def should_cancel(self): - return self._canceled or xbmc.Monitor().abortRequested() + return self._canceled or app.APP.monitor.abortRequested() def isValid(self): return not self.finished and not self._canceled @@ -370,7 +368,7 @@ class BackgroundWorker(object): return self def aborted(self): - return self._abort or xbmc.Monitor().abortRequested() + return self._abort or app.APP.monitor.abortRequested() def start(self): if self._thread and self._thread.isAlive(): @@ -452,7 +450,7 @@ class BackgroundThreader: return self def aborted(self): - return self._abort or xbmc.Monitor().abortRequested() + return self._abort or app.APP.monitor.abortRequested() def shutdown(self, block=True): self.abort()