def _wait_for_step(emr_connection, step, jobflowid, sleeptime):
 sleep(180)
 start = time()
 step_state = get_step_state(emr_connection, jobflowid, step.name, update=True)
 while (step_state in (LIVE_STATES + [PENDING])):
  sleep(sleeptime)
  step_state = get_step_state(emr_connection, jobflowid, step.name)
 end = time()
 print ('%s took %0.2fs (exit: %s)' % (step.name, (end - start), step_state))
 return step_state

def _wait_for_step ( emr_connection , step , jobflowid , sleeptime ) : sleep ( 180 ) start = time ( ) step_state = get_step_state ( emr_connection , jobflowid , step . name , update = True ) while ( step_state in ( LIVE_STATES + [ PENDING ] ) ) : sleep ( sleeptime ) step_state = get_step_state ( emr_connection , jobflowid , step . name ) end = time ( ) print ( '%s took %0.2fs (exit: %s)' % ( step . name , ( end - start ) , step_state ) ) return step_state
poll emr and wait for a step to finish .