def tick():
    unixIPC.tick()
#timeouts
last_db_check = time.time()

while True:
    if ( not scheduledb.connected() ):
        scheduledb.connect()
    else:
        if ( time.time() - last_db_check > DB_CHECK_INTERVAL ):
            check_db()
            last_db_check = time.time()
        
    if ( not unixIPC.connected ):
        unixIPC.reconnect()
    else:
        msgs = unixIPC.tick()
        for type,msg,client in msgs:
            if type=='scheduler_cmd_pb2':
                scheduler_cmd_msg = scheduler_cmd_pb2.Scheduler_Cmd();
                scheduler_cmd_msg.ParseFromString(msg)
                if scheduler_cmd_msg.command == scheduler_cmd_pb2.Scheduler_Cmd.FORCE_START:
                    task = scheduledb.get_task_by_id(scheduler_cmd_msg.task_id)
                    if ( task != None ):
                        child_start_task(task)
                    else:
                        print "Error task ID %d not found"%scheduler_cmd_msg.task_id
                elif scheduler_cmd_msg.command == scheduler_cmd_pb2.Scheduler_Cmd.PAUSE:
                    child = find_child_by_id(scheduler_cmd_msg.task_id)
                    if ( child != None ):
                        child_pause(child)
                    else:
def tick():
    return unixIPC.tick()