def run(): TaskManager.keepRunning = True # Don't know why, but with django 1.8, must "reset" connections so them do not fail on first access... # Is simmilar to https://code.djangoproject.com/ticket/21597#comment:29 connection.close() # Releases owned schedules so anyone can access them... Scheduler.releaseOwnShedules() TaskManager.registerScheduledTasks() noSchedulers = GlobalConfig.SCHEDULER_THREADS.getInt() noDelayedTasks = GlobalConfig.DELAYED_TASKS_THREADS.getInt() logger.info('Starting {0} schedulers and {1} task executors'.format( noSchedulers, noDelayedTasks)) threads = [] for _ in range(noSchedulers): thread = SchedulerThread() thread.start() threads.append(thread) time.sleep(0.5) for _ in range(noDelayedTasks): thread = DelayedTaskThread() thread.start() threads.append(thread) time.sleep(0.5) signal.signal(signal.SIGTERM, TaskManager.sigTerm) # Debugging stuff # import guppy # from guppy.heapy import Remote # Remote.on() # gc.set_debug(gc.DEBUG_LEAK) while TaskManager.keepRunning: time.sleep(1) for thread in threads: thread.notifyTermination()
def run(): TaskManager.keepRunning = True # Don't know why, but with django 1.8, must "reset" connections so them do not fail on first access... # Is simmilar to https://code.djangoproject.com/ticket/21597#comment:29 connection.close() # Releases owned schedules so anyone can access them... Scheduler.releaseOwnShedules() TaskManager.registerScheduledTasks() noSchedulers = GlobalConfig.SCHEDULER_THREADS.getInt() noDelayedTasks = GlobalConfig.DELAYED_TASKS_THREADS.getInt() logger.info('Starting {0} schedulers and {1} task executors'.format(noSchedulers, noDelayedTasks)) threads = [] for _ in range(noSchedulers): thread = SchedulerThread() thread.start() threads.append(thread) time.sleep(0.5) for _ in range(noDelayedTasks): thread = DelayedTaskThread() thread.start() threads.append(thread) time.sleep(1) signal.signal(signal.SIGTERM, TaskManager.sigTerm) # Debugging stuff # import guppy # from guppy.heapy import Remote # Remote.on() # gc.set_debug(gc.DEBUG_LEAK) while(TaskManager.keepRunning): time.sleep(1) for thread in threads: thread.notifyTermination()
def run(): TaskManager.keepRunning = True # Runs Scheduler in a separate thread and DelayedTasks here Scheduler.releaseOwnShedules() TaskManager.registerScheduledTasks() noSchedulers = GlobalConfig.SCHEDULER_THREADS.getInt() noDelayedTasks = GlobalConfig.DELAYED_TASKS_THREADS.getInt() logger.info('Starting {0} schedulers and {1} task executors'.format( noSchedulers, noDelayedTasks)) threads = [] for _ in range(noSchedulers): thread = SchedulerThread() thread.start() threads.append(thread) time.sleep(0.5) for _ in range(noDelayedTasks): thread = DelayedTaskThread() thread.start() threads.append(thread) time.sleep(1) signal.signal(signal.SIGTERM, TaskManager.sigTerm) # Debugging stuff # import guppy # from guppy.heapy import Remote # Remote.on() # gc.set_debug(gc.DEBUG_LEAK) while (TaskManager.keepRunning): time.sleep(1) for thread in threads: thread.notifyTermination()
def notifyTermination(self): Scheduler.scheduler().notifyTermination()
def run(self): Scheduler.scheduler().run()