Added a post_processor lock to only run one pp thread at a time

This commit is contained in:
rembo10
2012-07-17 17:09:35 +05:30
parent e56866028f
commit e1185d1fa2
+15 -12
View File
@@ -25,26 +25,29 @@ from lib.beets.mediafile import MediaFile
import headphones import headphones
from headphones import db, albumart, lyrics, logger, helpers from headphones import db, albumart, lyrics, logger, helpers
postprocessor_lock = threading.Lock()
def checkFolder(): def checkFolder():
myDB = db.DBConnection() with postprocessor_lock:
snatched = myDB.select('SELECT * from snatched WHERE Status="Snatched"')
for album in snatched: myDB = db.DBConnection()
snatched = myDB.select('SELECT * from snatched WHERE Status="Snatched"')
if album['FolderName']: for album in snatched:
nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, album['FolderName']).encode(headphones.SYS_ENCODING) if album['FolderName']:
torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING)
if os.path.exists(nzb_album_path): nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, album['FolderName']).encode(headphones.SYS_ENCODING)
logger.debug('Found %s in NZB download folder. Verifying....' % album['FolderName']) torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING)
verify(album['AlbumID'], nzb_album_path)
elif os.path.exists(torrent_album_path): if os.path.exists(nzb_album_path):
logger.debug('Found %s in torrent download folder. Verifying....' % album['FolderName']) logger.debug('Found %s in NZB download folder. Verifying....' % album['FolderName'])
verify(album['AlbumID'], torrent_album_path) verify(album['AlbumID'], nzb_album_path)
elif os.path.exists(torrent_album_path):
logger.debug('Found %s in torrent download folder. Verifying....' % album['FolderName'])
verify(album['AlbumID'], torrent_album_path)
def verify(albumid, albumpath): def verify(albumid, albumpath):