Adjust lock modification

This commit is contained in:
angelblue05 2018-10-03 17:18:05 -05:00
parent 66a8a5161a
commit 949714f22a

View file

@ -526,21 +526,21 @@ class UpdatedWorker(threading.Thread):
def run(self): def run(self):
with self.database as kodidb: with self.lock:
with Database('emby') as embydb: with self.database as kodidb:
with Database('emby') as embydb:
while True: while True:
try: try:
item = self.queue.get(timeout=3) item = self.queue.get(timeout=3)
except Queue.Empty: except Queue.Empty:
LOG.info("--<[ q:updated/%s ]", id(self)) LOG.info("--<[ q:updated/%s ]", id(self))
self.is_done = True self.is_done = True
break break
with self.lock:
obj = MEDIA[item['Type']](self.args[0], embydb, kodidb, self.args[1])[item['Type']] obj = MEDIA[item['Type']](self.args[0], embydb, kodidb, self.args[1])[item['Type']]
try: try:
@ -551,10 +551,10 @@ class UpdatedWorker(threading.Thread):
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
self.queue.task_done() self.queue.task_done()
if window('emby_should_stop.bool'): if window('emby_should_stop.bool'):
break break
class UserDataWorker(threading.Thread): class UserDataWorker(threading.Thread):
@ -570,21 +570,21 @@ class UserDataWorker(threading.Thread):
def run(self): def run(self):
with self.database as kodidb: with self.lock:
with Database('emby') as embydb: with self.database as kodidb:
with Database('emby') as embydb:
while True: while True:
try: try:
item = self.queue.get(timeout=3) item = self.queue.get(timeout=3)
except Queue.Empty: except Queue.Empty:
LOG.info("--<[ q:userdata/%s ]", id(self)) LOG.info("--<[ q:userdata/%s ]", id(self))
self.is_done = True self.is_done = True
break break
with self.lock:
obj = MEDIA[item['Type']](self.args[0], embydb, kodidb, self.args[1])['UserData'] obj = MEDIA[item['Type']](self.args[0], embydb, kodidb, self.args[1])['UserData']
try: try:
@ -595,10 +595,10 @@ class UserDataWorker(threading.Thread):
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
self.queue.task_done() self.queue.task_done()
if window('emby_should_stop.bool'): if window('emby_should_stop.bool'):
break break
class SortWorker(threading.Thread): class SortWorker(threading.Thread):
@ -658,21 +658,21 @@ class RemovedWorker(threading.Thread):
def run(self): def run(self):
with self.database as kodidb: with self.lock:
with Database('emby') as embydb: with self.database as kodidb:
with Database('emby') as embydb:
while True: while True:
try: try:
item = self.queue.get(timeout=2) item = self.queue.get(timeout=2)
except Queue.Empty: except Queue.Empty:
LOG.info("--<[ q:removed/%s ]", id(self)) LOG.info("--<[ q:removed/%s ]", id(self))
self.is_done = True self.is_done = True
break break
with self.lock:
obj = MEDIA[item['Type']](self.args[0], embydb, kodidb, self.args[1])['Remove'] obj = MEDIA[item['Type']](self.args[0], embydb, kodidb, self.args[1])['Remove']
try: try:
@ -683,10 +683,10 @@ class RemovedWorker(threading.Thread):
except Exception as error: except Exception as error:
LOG.exception(error) LOG.exception(error)
self.queue.task_done() self.queue.task_done()
if window('emby_should_stop.bool'): if window('emby_should_stop.bool'):
break break
class NotifyWorker(threading.Thread): class NotifyWorker(threading.Thread):