def wait_for_status(client, stream_name, status, wait_timeout=300, check_mode=False):
 polling_increment_secs = 5
 wait_timeout = (time.time() + wait_timeout)
 status_achieved = False
 stream = dict()
 err_msg = ''
 while (wait_timeout > time.time()):
  try:
   (find_success, find_msg, stream) = find_stream(client, stream_name, check_mode=check_mode)
   if check_mode:
    status_achieved = True
    break
   elif (status != 'DELETING'):
    if (find_success and stream):
     if (stream.get('StreamStatus') == status):
      status_achieved = True
      break
   elif ((status == 'DELETING') and (not check_mode)):
    if (not find_success):
     status_achieved = True
     break
   else:
    time.sleep(polling_increment_secs)
  except botocore.exceptions.ClientError as e:
   err_msg = str(e)
 if (not status_achieved):
  err_msg = 'Wait time out reached, while waiting for results'
 else:
  err_msg = 'Status {0} achieved successfully'.format(status)
 return (status_achieved, err_msg, stream)

def wait_for_status ( client , stream_name , status , wait_timeout = 300 , check_mode = False ) : polling_increment_secs = 5 wait_timeout = ( time . time ( ) + wait_timeout ) status_achieved = False stream = dict ( ) err_msg = '' while ( wait_timeout > time . time ( ) ) : try : ( find_success , find_msg , stream ) = find_stream ( client , stream_name , check_mode = check_mode ) if check_mode : status_achieved = True break elif ( status != 'DELETING' ) : if ( find_success and stream ) : if ( stream . get ( 'StreamStatus' ) == status ) : status_achieved = True break elif ( ( status == 'DELETING' ) and ( not check_mode ) ) : if ( not find_success ) : status_achieved = True break else : time . sleep ( polling_increment_secs ) except botocore . exceptions . ClientError as e : err_msg = str ( e ) if ( not status_achieved ) : err_msg = 'Wait time out reached, while waiting for results' else : err_msg = 'Status {0} achieved successfully' . format ( status ) return ( status_achieved , err_msg , stream )
wait for the nat gateway to reach a status args: client : boto3 client wait_timeout : number of seconds to wait .