Remove sleep from Manage Artists refresh. Also, only use a single thread for refreshing a list of multiple selected artists.

This commit is contained in:
Palli
2012-01-08 22:50:59 +00:00
parent 07d645e1fd
commit 633e2a1450
2 changed files with 10 additions and 3 deletions

View File

@@ -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):

View File

@@ -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