Don't run multiple searches at once
This commit is contained in:
@@ -16,6 +16,8 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class Searcher(Plugin):
|
class Searcher(Plugin):
|
||||||
|
|
||||||
|
in_progress = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('searcher.all', self.all_movies)
|
addEvent('searcher.all', self.all_movies)
|
||||||
addEvent('searcher.single', self.single)
|
addEvent('searcher.single', self.single)
|
||||||
@@ -27,6 +29,12 @@ class Searcher(Plugin):
|
|||||||
|
|
||||||
def all_movies(self):
|
def all_movies(self):
|
||||||
|
|
||||||
|
if self.in_progress:
|
||||||
|
log.info('Search already in progress')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.in_progress = True
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
movies = db.query(Movie).filter(
|
movies = db.query(Movie).filter(
|
||||||
@@ -52,6 +60,8 @@ class Searcher(Plugin):
|
|||||||
if self.shuttingDown():
|
if self.shuttingDown():
|
||||||
break
|
break
|
||||||
|
|
||||||
|
self.in_progress = False
|
||||||
|
|
||||||
def single(self, movie):
|
def single(self, movie):
|
||||||
|
|
||||||
available_status = fireEvent('status.get', 'available', single = True)
|
available_status = fireEvent('status.get', 'available', single = True)
|
||||||
|
|||||||
Reference in New Issue
Block a user