1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

PEP* Cleanups and added timeouts for threads when shutting down or restarting.

This commit is contained in:
echel0n 2014-07-27 18:01:26 -07:00
parent 1908f76eaf
commit cef53beee0
2 changed files with 13 additions and 18 deletions

View File

@ -1177,63 +1177,63 @@ def halt():
dailySearchScheduler.stop.set() dailySearchScheduler.stop.set()
logger.log(u"Waiting for the DAILYSEARCH thread to exit") logger.log(u"Waiting for the DAILYSEARCH thread to exit")
try: try:
dailySearchScheduler.join() dailySearchScheduler.join(10)
except: except:
pass pass
backlogSearchScheduler.stop.set() backlogSearchScheduler.stop.set()
logger.log(u"Waiting for the BACKLOG thread to exit") logger.log(u"Waiting for the BACKLOG thread to exit")
try: try:
backlogSearchScheduler.join() backlogSearchScheduler.join(10)
except: except:
pass pass
showUpdateScheduler.stop.set() showUpdateScheduler.stop.set()
logger.log(u"Waiting for the SHOWUPDATER thread to exit") logger.log(u"Waiting for the SHOWUPDATER thread to exit")
try: try:
showUpdateScheduler.join() showUpdateScheduler.join(10)
except: except:
pass pass
versionCheckScheduler.stop.set() versionCheckScheduler.stop.set()
logger.log(u"Waiting for the VERSIONCHECKER thread to exit") logger.log(u"Waiting for the VERSIONCHECKER thread to exit")
try: try:
versionCheckScheduler.join() versionCheckScheduler.join(10)
except: except:
pass pass
showQueueScheduler.stop.set() showQueueScheduler.stop.set()
logger.log(u"Waiting for the SHOWQUEUE thread to exit") logger.log(u"Waiting for the SHOWQUEUE thread to exit")
try: try:
showQueueScheduler.join() showQueueScheduler.join(10)
except: except:
pass pass
searchQueueScheduler.stop.set() searchQueueScheduler.stop.set()
logger.log(u"Waiting for the SEARCHQUEUE thread to exit") logger.log(u"Waiting for the SEARCHQUEUE thread to exit")
try: try:
searchQueueScheduler.join() searchQueueScheduler.join(10)
except: except:
pass pass
autoPostProcesserScheduler.stop.set() autoPostProcesserScheduler.stop.set()
logger.log(u"Waiting for the POSTPROCESSER thread to exit") logger.log(u"Waiting for the POSTPROCESSER thread to exit")
try: try:
autoPostProcesserScheduler.join() autoPostProcesserScheduler.join(10)
except: except:
pass pass
traktCheckerScheduler.stop.set() traktCheckerScheduler.stop.set()
logger.log(u"Waiting for the TRAKTCHECKER thread to exit") logger.log(u"Waiting for the TRAKTCHECKER thread to exit")
try: try:
traktCheckerScheduler.join() traktCheckerScheduler.join(10)
except: except:
pass pass
properFinderScheduler.stop.set() properFinderScheduler.stop.set()
logger.log(u"Waiting for the PROPERFINDER thread to exit") logger.log(u"Waiting for the PROPERFINDER thread to exit")
try: try:
properFinderScheduler.join() properFinderScheduler.join(10)
except: except:
pass pass

View File

@ -15,7 +15,7 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
import time
import os import os
import traceback import traceback
@ -24,8 +24,7 @@ from sickbeard import encodingKludge as ek
from sickbeard import logger from sickbeard import logger
from sickbeard import helpers from sickbeard import helpers
from sickbeard import search_queue from sickbeard import search_queue
from sickbeard import db from sickbeard.common import SKIPPED, WANTED
from sickbeard.common import SNATCHED, SNATCHED_PROPER, DOWNLOADED, SKIPPED, UNAIRED, IGNORED, ARCHIVED, WANTED, UNKNOWN
from lib.trakt import * from lib.trakt import *
@ -61,11 +60,7 @@ class TraktChecker():
logger.log(u"Could not connect to trakt service, aborting library check", logger.ERROR) logger.log(u"Could not connect to trakt service, aborting library check", logger.ERROR)
return return
for show in library: return filter(lambda x: int(indexerid) in [int(x.tvdb_id), int(x.tvrage_id)], library)
if int(indexer) == 1 and int(show['tvdb_id']) == int(indexerid):
return show
elif int(indexer) == 2 and int(show['tvrage_id']) == int(indexerid):
return show
def syncLibrary(self): def syncLibrary(self):
logger.log(u"Syncing library to trakt.tv show library", logger.DEBUG) logger.log(u"Syncing library to trakt.tv show library", logger.DEBUG)
@ -112,7 +107,7 @@ class TraktChecker():
data['title'] = show_obj.name data['title'] = show_obj.name
data['year'] = show_obj.startyear data['year'] = show_obj.startyear
if data is not None: if data:
logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG) logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG)
TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data) data)