def init_tasks():
 db = Database()
 cfg = Config()
 log.debug('Checking for locked tasks..')
 for task in db.list_tasks(status=TASK_RUNNING):
  if cfg.cuckoo.reschedule:
   task_id = db.reschedule(task.id)
   log.info('Rescheduled task with ID %s and target %s: task #%s', task.id, task.target, task_id)
  else:
   db.set_status(task.id, TASK_FAILED_ANALYSIS)
   log.info('Updated running task ID {0} status to failed_analysis'.format(task.id))
 log.debug('Checking for pending service tasks..')
 for task in db.list_tasks(status=TASK_PENDING, category='service'):
  db.set_status(task.id, TASK_FAILED_ANALYSIS)

def init_tasks ( ) : db = Database ( ) cfg = Config ( ) log . debug ( 'Checking for locked tasks..' ) for task in db . list_tasks ( status = TASK_RUNNING ) : if cfg . cuckoo . reschedule : task_id = db . reschedule ( task . id ) log . info ( 'Rescheduled task with ID %s and target %s: task #%s' , task . id , task . target , task_id ) else : db . set_status ( task . id , TASK_FAILED_ANALYSIS ) log . info ( 'Updated running task ID {0} status to failed_analysis' . format ( task . id ) ) log . debug ( 'Checking for pending service tasks..' ) for task in db . list_tasks ( status = TASK_PENDING , category = 'service' ) : db . set_status ( task . id , TASK_FAILED_ANALYSIS )
check tasks and reschedule uncompleted ones .