mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-20 10:35:32 +01:00
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:
@@ -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):
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user