|
|
@ -27,7 +27,7 @@ from sickbeard.exceptions import ex |
|
|
|
|
|
|
|
class Scheduler: |
|
|
|
def __init__(self, action, cycleTime=datetime.timedelta(minutes=10), runImmediately=True, |
|
|
|
threadName="ScheduledThread", silent=False, runOnce=False, queue=None): |
|
|
|
threadName="ScheduledThread", silent=False, runOnce=False): |
|
|
|
|
|
|
|
if runImmediately: |
|
|
|
self.lastRun = datetime.datetime.fromordinal(1) |
|
|
@ -45,7 +45,6 @@ class Scheduler: |
|
|
|
|
|
|
|
self.abort = False |
|
|
|
self.runOnce = runOnce |
|
|
|
self.queue = queue |
|
|
|
|
|
|
|
def initThread(self): |
|
|
|
if self.thread == None or not self.thread.isAlive(): |
|
|
@ -72,11 +71,7 @@ class Scheduler: |
|
|
|
if not self.silent: |
|
|
|
logger.log(u"Starting new thread: " + self.threadName, logger.DEBUG) |
|
|
|
|
|
|
|
# check if we want to pass in our queue dynamically |
|
|
|
if self.queue: |
|
|
|
self.action.run(self.queue) |
|
|
|
else: |
|
|
|
self.action.run() |
|
|
|
self.action.run() |
|
|
|
except Exception, e: |
|
|
|
logger.log(u"Exception generated in thread " + self.threadName + ": " + ex(e), logger.ERROR) |
|
|
|
logger.log(repr(traceback.format_exc()), logger.DEBUG) |
|
|
|