def build_check():
    global BUILD_KILL,WAIT_TILL_CLEAR
    while True:
        build = check_for_new_build(get_current_build())  #pending : implement the build-check thread to wait till 
        BUILD_KILL = True  #pending : implement the build-check thread to wait till all the runs are safely shutdown
        time.sleep(4)
        k = time.time()
        while  WAIT_TILL_CLEAR:
            assert (time.time() - k) < 500
            print 'waiting to clear all the apps'
            time.sleep(2)
        while  WAIT_TILL_CLEAR:
            assert (time.time() - k) < 500
            print 'waiting to clear all the apps'
            time.sleep(2)
        

if __name__ == '__main__':
    opts,args = opts()
    master_conf = opts.conf
    smokes_mode = opts.build
    simple_harness = opts.plain
    path_to_build = opts.path
    curr = opts.current
    if not simple_harness:
        if curr:
            build = get_current_build(path_to_build)
        else :
            build = check_for_new_build(get_current_build(path_to_build),path_to_build)
        th = threading.Thread(target=build_check)
        th.daemon = True
        th.start()
    while True:
        try:
            build = ''
            if not simple_harness:
                build = get_current_build(path_to_build)
            implementation(master_conf,build)
        except BuildRestart:
            if smokes_mode:
                reset_vals()
                print '----------------restarting----------------'