asana_hub/transport.py
def transport_task(func):
    """Decorator for retrying tasks with special cases."""

    def wrapped_func(*args, **kwargs):
        tries = 0
        while True:
            try:
                try:
                    return func(*args, **kwargs)

                except (asana_errors.InvalidRequestError,
                        asana_errors.NotFoundError), exc:
                    logging.warn("warning: invalid request: %r", exc)

                except asana_errors.ForbiddenError, exc:
                    logging.warn("forbidden error: %r", exc)

                except asana_errors.NotFoundError, exc:
                    logging.warn("not found error: %r", exc)

                return None
            except asana_errors.RetryableAsanaError, retry_exc:
                tries += 1
                logging.warn("retry exception %r on try %d", retry_exc, tries)

                if tries >= 3:
                    raise
            except Exception, exc:
                logging.exception("Exception in transport.")
                return

    return wrapped_func
def transport_task(func):
    def wrapped_func(*args, **kwargs):
        tries = 0
        while True:
            try:
                try:
                    return func(*args, **kwargs)

                except (asana_errors.InvalidRequestError,
                        asana_errors.NotFoundError), exc:
                    logging.warn("warning: invalid request: %r", exc)

                except asana_errors.ForbiddenError, exc:
                    logging.warn("forbidden error: %r", exc)

                except asana_errors.NotFoundError, exc:
                    logging.warn("not found error: %r", exc)

                return None
            except asana_errors.RetryableAsanaError, retry_exc:
                tries += 1
                logging.warn("retry exception %r on try %d", retry_exc, tries)

                if tries >= 3:
                    raise
            except Exception, exc:
                logging.exception("Exception in transport.")
                return

    return wrapped_func
def transport_task ( func ) : def wrapped_func ( * args , * * kwargs ) : tries = 0 while True : try : try : return func ( * args , * * kwargs ) except ( asana_errors . InvalidRequestError , asana_errors . NotFoundError ) , exc : logging . warn ( "warning: invalid request: %r" , exc ) except asana_errors . ForbiddenError , exc : logging . warn ( "forbidden error: %r" , exc ) except asana_errors . NotFoundError , exc : logging . warn ( "not found error: %r" , exc ) return None except asana_errors . RetryableAsanaError , retry_exc : tries += 1 logging . warn ( "retry exception %r on try %d" , retry_exc , tries ) if tries >= 3 : raise except Exception , exc : logging . exception ( "Exception in transport." ) return return wrapped_func
Decorator for retrying tasks with special cases.
Decorator for retrying tasks with special cases .