def wrap_aws_conn(raw_conn):
 def retry_if(ex):
  'Retry if we get a server error indicating throttling. Also\n        handle spurious 505s that are thought to be part of a load\n        balancer issue inside AWS.'
  return ((isinstance(ex, boto.exception.BotoServerError) and (('Throttling' in ex.body) or ('RequestExpired' in ex.body) or (ex.status == 505))) or (isinstance(ex, socket.error) and (ex.args in ((104, 'Connection reset by peer'), (110, 'Connection timed out')))))
 return RetryWrapper(raw_conn, retry_if=retry_if, backoff=_EMR_BACKOFF, multiplier=_EMR_BACKOFF_MULTIPLIER, max_tries=_EMR_MAX_TRIES)

def wrap_aws_conn ( raw_conn ) : def retry_if ( ex ) : return ( ( isinstance ( ex , boto . exception . BotoServerError ) and ( ( 'Throttling' in ex . body ) or ( 'RequestExpired' in ex . body ) or ( ex . status == 505 ) ) ) or ( isinstance ( ex , socket . error ) and ( ex . args in ( ( 104 , 'Connection reset by peer' ) , ( 110 , 'Connection timed out' ) ) ) ) ) return RetryWrapper ( raw_conn , retry_if = retry_if , backoff = _EMR_BACKOFF , multiplier = _EMR_BACKOFF_MULTIPLIER , max_tries = _EMR_MAX_TRIES )
wrap a given boto connection object so that it can retry when throttled .