def retry_if(predicate):
 def should_retry(exc_type, value, traceback):
  if predicate(value):
   return None
  raise exc_type, value, traceback
 return should_retry

def retry_if ( predicate ) : def should_retry ( exc_type , value , traceback ) : if predicate ( value ) : return None raise exc_type , value , traceback return should_retry
create a predicate compatible with with_retry which will retry if the raised exception satisfies the given predicate .