# ======================= # get_task_id_of_db_build # ======================= subroutine(get_task_id_of_db_build( string profile_name, int max_time), ( # max_time specifies the maximum time to look up the task_id for the database build string task_id; int time_delay = 1000; int time_elapsed = 0; if (max_time <= time_delay) then ( max_time = time_delay + 100; ); while (task_id eq "" and (time_elapsed < max_time)) ( # TEMP if (node_exists("volatile.error_message")) then ( debug_message("\n\n\n\n\n\n\n volatile.error_message NODE EXISTS \n\n\n\n\n\n\n"); sleep_milliseconds(6000); ) else ( debug_message("\n\n\n\n\n\n\n volatile.error_message NODE DOES NOT EXIST \n\n\n\n\n\n\n"); ); # TEMP END debug_message("\n\n@@@@ Looking for task which is updating/building database for $profile_name\n"); get_task_info("volatile.task_info"); node task; debug_message("#### #### task_info: " . node_as_string("volatile.task_info") . "\n"); foreach task "volatile.task_info" ( if (node_value(subnode_by_name(task, "active")) and node_value(subnode_by_name(task, "writing_db")) and (node_value(subnode_by_name(task, "profile")) eq profile_name)) then ( task_id = node_name(task); debug_message("@@@@ Task $task_id is writing db for $profile_name\n"); debug_message("@@@@ Got the task_id $task_id after $time_elapsed milliseconds\n"); last; ); ); if (task_id eq "") then ( debug_message("\n@@@@ NO TASK_ID FOUND FOR EXISTING BUILD; RETRYING\n\n"); sleep_milliseconds(time_delay); ); time_elapsed = time_elapsed + time_delay; # debug_message("\n\n@@@@ get_task_id_of_db_build - max_time: $max_time \n"); # debug_message("@@@@ get_task_id_of_db_build - time_delay: time_delay"); # debug_message("@@@@ get_task_id_of_db_build - time_elapsed: $time_elapsed \n\n"); ); debug_message("\n\n@@@@ get_task_id_of_db_build(), task_id: $task_id \n"); task_id; ));