From 8546f5711c2b08f1d8e586e47666475a0dbc99e1 Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 16:35:16 +0000 Subject: [PATCH 1/7] Remove sleep from forced artist update --- headphones/webserve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 812d8ceb..abc22711 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -266,7 +266,6 @@ class WebInterface(object): def forceUpdate(self): from headphones import updater threading.Thread(target=updater.dbUpdate).start() - time.sleep(5) raise cherrypy.HTTPRedirect("home") forceUpdate.exposed = True From 9fda83ced2865e7dfa2c22660fd381d501cb4c89 Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 16:43:24 +0000 Subject: [PATCH 2/7] Remove sleep from get extras action --- headphones/webserve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index abc22711..03c6d520 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -82,7 +82,6 @@ class WebInterface(object): newValueDict = {'IncludeExtras': 1} myDB.upsert("artists", newValueDict, controlValueDict) threading.Thread(target=importer.addArtisttoDB, args=[ArtistID, True]).start() - time.sleep(10) raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) getExtras.exposed = True From ed8641ccb7dedb861dbebdb149d2fe7218a2ca4f Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 16:54:46 +0000 Subject: [PATCH 3/7] Remove sleep from forced wanted album search --- headphones/webserve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 03c6d520..3e59f0e5 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -271,7 +271,6 @@ class WebInterface(object): def forceSearch(self): from headphones import searcher threading.Thread(target=searcher.searchforalbum).start() - time.sleep(5) raise cherrypy.HTTPRedirect("home") forceSearch.exposed = True From 07d645e1fdff2f6f2dc2c3bd32cf5d89f943b928 Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 16:57:39 +0000 Subject: [PATCH 4/7] Remove sleep from forced post processing --- headphones/webserve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 3e59f0e5..0522b0c1 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -277,7 +277,6 @@ class WebInterface(object): def forcePostProcess(self): from headphones import postprocessor threading.Thread(target=postprocessor.forcePostProcess).start() - time.sleep(5) raise cherrypy.HTTPRedirect("home") forcePostProcess.exposed = True From 633e2a14500011861d4fce50c4a49e0f304ff1c1 Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 22:50:59 +0000 Subject: [PATCH 5/7] Remove sleep from Manage Artists refresh. Also, only use a single thread for refreshing a list of multiple selected artists. --- headphones/importer.py | 5 +++++ headphones/webserve.py | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index ca8c8134..c933e656 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -59,6 +59,11 @@ def artistlist_to_mbids(artistlist, forced=False): except Exception, e: logger.warn('Failed to update arist information from Last.fm: %s' % e) +def addArtistIDListToDB(artistidlist): + # Used to add a list of artist IDs to the database in a single thread + logger.debug("Importer: Adding artist ids %s" % artistidlist) + for artistid in artistidlist: + addArtisttoDB(artistid) def addArtisttoDB(artistid, extrasonly=False): diff --git a/headphones/webserve.py b/headphones/webserve.py index 0522b0c1..2338be4b 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -211,6 +211,7 @@ class WebInterface(object): def markArtists(self, action=None, **args): myDB = db.DBConnection() + artistsToAdd = [] for ArtistID in args: if action == 'delete': myDB.action('DELETE from artists WHERE ArtistID=?', [ArtistID]) @@ -225,9 +226,10 @@ class WebInterface(object): newValueDict = {'Status': 'Active'} myDB.upsert("artists", newValueDict, controlValueDict) else: - # These may and probably will collide - need to make a better way to queue musicbrainz queries - threading.Thread(target=importer.addArtisttoDB, args=[ArtistID]).start() - time.sleep(30) + artistsToAdd.append(ArtistID) + if len(artistsToAdd) > 0: + logger.debug("Refreshing artists: %s" % artistsToAdd) + threading.Thread(target=importer.addArtistIDListToDB, args=[artistsToAdd]).start() raise cherrypy.HTTPRedirect("home") markArtists.exposed = True From 4063015a1da274d852fa98c6e02ee2fa775b72f7 Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 23:10:38 +0000 Subject: [PATCH 6/7] Remove sleep from add release from search results --- headphones/webserve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 2338be4b..5518884a 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -485,7 +485,6 @@ class WebInterface(object): def addReleaseById(self, rid): threading.Thread(target=importer.addReleaseById, args=[rid]).start() - time.sleep(5) raise cherrypy.HTTPRedirect("home") addReleaseById.exposed = True From 80f281cf8a14e09ed5d18e746c71d1fbcfea4755 Mon Sep 17 00:00:00 2001 From: Palli Date: Sun, 8 Jan 2012 23:13:21 +0000 Subject: [PATCH 7/7] Remove sleep from add artists from Manage New page --- headphones/webserve.py | 1 - 1 file changed, 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 5518884a..13eb4272 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -151,7 +151,6 @@ class WebInterface(object): def addArtists(self, **args): threading.Thread(target=importer.artistlist_to_mbids, args=[args, True]).start() - time.sleep(5) raise cherrypy.HTTPRedirect("home") addArtists.exposed = True