Allura/allura/lib/helpers.py
def urlopen(url, retries=3, codes=(408, 500, 502, 503, 504), timeout=None):
    """Open url, optionally retrying if an error is encountered.

    Socket and other IO errors will always be retried if retries > 0.
    HTTP errors are retried if the error code is passed in ``codes``.

    :param retries: Number of time to retry.
    :param codes: HTTP error codes that should be retried.

    """
    attempts = 0
    while True:
        try:
            return urllib2.urlopen(url, timeout=timeout)
        except IOError as e:
            no_retry = isinstance(e, urllib2.HTTPError) and e.code not in codes
            if attempts < retries and not no_retry:
                attempts += 1
                continue
            else:
                try:
                    url_string = url.get_full_url()  # if url is Request obj
                except Exception:
                    url_string = url
                if timeout is None:
                    timeout = socket.getdefaulttimeout()
                log.exception(
                    'Failed after %s retries on url with a timeout of %s: %s: %s',
                    attempts, timeout, url_string, e)
                raise e
Open url, optionally retrying if an error is encountered.

    Socket and other IO errors will always be retried if retries > 0.
    HTTP errors are retried if the error code is passed in ``codes``.

    :param retries: Number of time to retry.
    :param codes: HTTP error codes that should be retried.

    
Open url, optionally retrying if an error is encountered.
Socket and other IO errors will always be retried if retries > 0.
HTTP errors are retried if the error code is passed in ``codes``.
Open url optionally retrying if an error is encountered . Socket and other IO errors will always be retried if retries > 0 . HTTP errors are retried if the error code is passed in ` ` codes ` ` .
def urlopen(url, retries=3, codes=(408, 500, 502, 503, 504), timeout=None):
    attempts = 0
    while True:
        try:
            return urllib2.urlopen(url, timeout=timeout)
        except IOError as e:
            no_retry = isinstance(e, urllib2.HTTPError) and e.code not in codes
            if attempts < retries and not no_retry:
                attempts += 1
                continue
            else:
                try:
                    url_string = url.get_full_url()  
                except Exception:
                    url_string = url
                if timeout is None:
                    timeout = socket.getdefaulttimeout()
                log.exception(
                    'Failed after %s retries on url with a timeout of %s: %s: %s',
                    attempts, timeout, url_string, e)
                raise e
def urlopen ( url , retries = 3 , codes = ( 408 , 500 , 502 , 503 , 504 ) , timeout = None ) : attempts = 0 while True : try : return urllib2 . urlopen ( url , timeout = timeout ) except IOError as e : no_retry = isinstance ( e , urllib2 . HTTPError ) and e . code not in codes if attempts < retries and not no_retry : attempts += 1 continue else : try : url_string = url . get_full_url ( ) except Exception : url_string = url if timeout is None : timeout = socket . getdefaulttimeout ( ) log . exception ( 'Failed after %s retries on url with a timeout of %s: %s: %s' , attempts , timeout , url_string , e ) raise e
Open url, optionally retrying if an error is encountered.
Open url optionally retrying if an error is encountered .
"""Open url, optionally retrying if an error is encountered.

    Socket and other IO errors will always be retried if retries > 0.
    HTTP errors are retried if the error code is passed in ``codes``.

    :param retries: Number of time to retry.
    :param codes: HTTP error codes that should be retried.

    """ # if url is Request obj
url
retries
Number of time to retry.
Number of time to retry .
codes
HTTP error codes that should be retried.
HTTP error codes that should be retried .
timeout