def reprovision_and_retry(func):
 @functools.wraps(func)
 def wrapper(*a, **kw):
  errback = kw.get('errback', None)
  if (errback is None):
   def errback(e):
    raise e
  def errback_wrapper(e):
   if (isinstance(e, UnknownAppID) and ('INITIAL' in OPTIONS)):
    try:
     for initial in OPTIONS['INITIAL']:
      provision(*initial)
     func(*a, **kw)
    except Exception as new_exc:
     errback(new_exc)
   else:
    errback(e)
  kw['errback'] = errback_wrapper
  return func(*a, **kw)
 return wrapper

def reprovision_and_retry ( func ) : @ functools . wraps ( func ) def wrapper ( * a , ** kw ) : errback = kw . get ( 'errback' , None ) if ( errback is None ) : def errback ( e ) : raise e def errback_wrapper ( e ) : if ( isinstance ( e , UnknownAppID ) and ( 'INITIAL' in OPTIONS ) ) : try : for initial in OPTIONS [ 'INITIAL' ] : provision ( * initial ) func ( * a , ** kw ) except Exception as new_exc : errback ( new_exc ) else : errback ( e ) kw [ 'errback' ] = errback_wrapper return func ( * a , ** kw ) return wrapper
wraps the errback callback of the api functions .