def wait_for_successful_query(url, wait_for=300, **kwargs):
 starttime = time.time()
 while True:
  caught_exception = None
  result = None
  try:
   result = query(url=url, **kwargs)
   if ((not result.get('Error')) and (not result.get('error'))):
    return result
  except Exception as exc:
   caught_exception = exc
  if (time.time() > (starttime + wait_for)):
   if ((not result) and caught_exception):
    raise caught_exception
   return result

def wait_for_successful_query ( url , wait_for = 300 , ** kwargs ) : starttime = time . time ( ) while True : caught_exception = None result = None try : result = query ( url = url , ** kwargs ) if ( ( not result . get ( 'Error' ) ) and ( not result . get ( 'error' ) ) ) : return result except Exception as exc : caught_exception = exc if ( time . time ( ) > ( starttime + wait_for ) ) : if ( ( not result ) and caught_exception ) : raise caught_exception return result
like query but .