def WaitForFlow(flow_urn, token=None, timeout=DEFAULT_TIMEOUT, max_sleep_time=1, min_sleep_time=0.2, dampening_multiplier=0.9):
 start_time = time.time()
 sleep_time = max_sleep_time
 while True:
  with aff4.FACTORY.Open(flow_urn, token=token, aff4_type=flow.GRRFlow) as flow_obj:
   if ((time.time() - start_time) > timeout):
    logging.warn('Timed out after waiting %ss for %s!', timeout, flow_obj)
    raise IOError('Timed out trying to access client! Is it connected?')
   if (not flow_obj.GetRunner().IsRunning()):
    break
  sleep_time = max((sleep_time * dampening_multiplier), min_sleep_time)
  time.sleep(sleep_time)
  logging.debug('Waiting for %s, sleeping for %.3fs', flow_obj, sleep_time)

def WaitForFlow ( flow_urn , token = None , timeout = DEFAULT_TIMEOUT , max_sleep_time = 1 , min_sleep_time = 0.2 , dampening_multiplier = 0.9 ) : start_time = time . time ( ) sleep_time = max_sleep_time while True : with aff4 . FACTORY . Open ( flow_urn , token = token , aff4_type = flow . GRRFlow ) as flow_obj : if ( ( time . time ( ) - start_time ) > timeout ) : logging . warn ( 'Timed out after waiting %ss for %s!' , timeout , flow_obj ) raise IOError ( 'Timed out trying to access client! Is it connected?' ) if ( not flow_obj . GetRunner ( ) . IsRunning ( ) ) : break sleep_time = max ( ( sleep_time * dampening_multiplier ) , min_sleep_time ) time . sleep ( sleep_time ) logging . debug ( 'Waiting for %s, sleeping for %.3fs' , flow_obj , sleep_time )
waits for a flow to finish .