def poll_for_callable(func, *args, **kwargs):
 timeout = 5
 if ('timeout' in kwargs):
  timeout = kwargs.pop('timeout')
 start = time()
 last_exception = None
 while ((time() - start) < timeout):
  try:
   func_args = []
   for arg in args:
    if callable(arg):
     func_args.append(arg())
    else:
     func_args.append(arg)
   func(*func_args)
  except AssertionError as e:
   last_exception = e
   sleep(0.1)
  else:
   return True
 raise (last_exception or AssertionError('No exception triggered yet'))

def poll_for_callable ( func , * args , ** kwargs ) : timeout = 5 if ( 'timeout' in kwargs ) : timeout = kwargs . pop ( 'timeout' ) start = time ( ) last_exception = None while ( ( time ( ) - start ) < timeout ) : try : func_args = [ ] for arg in args : if callable ( arg ) : func_args . append ( arg ( ) ) else : func_args . append ( arg ) func ( * func_args ) except AssertionError as e : last_exception = e sleep ( 0.1 ) else : return True raise ( last_exception or AssertionError ( 'No exception triggered yet' ) )
replay to update the status during timeout seconds .