Esempio n. 1
0
    def callback(e):
        if isinstance(e, TRANSIENT_NETWORK_ERRS):
            occurrences[0] += 1
            if occurrences[0] < 20:
                return
        else:
            occurrences[0] = 1

        if account_id:
            try:
                with session_scope(account_id) as db_session:
                    account = db_session.query(Account).get(account_id)
                    sync_error = account.sync_error
                    if not sync_error or isinstance(sync_error, basestring):
                        account.update_sync_error(e)
                        db_session.commit()
            except:
                logger.error('Error saving sync_error to account object',
                             account_id=account_id,
                             **create_error_log_context(sys.exc_info()))

        log_uncaught_errors(logger,
                            account_id=account_id,
                            provider=provider,
                            occurrences=occurrences[0])
Esempio n. 2
0
    def callback(e):
        is_transient = isinstance(e, TRANSIENT_NETWORK_ERRS)
        mysql_error = None

        log = logger or get_logger()

        if isinstance(e, _mysql_exceptions.OperationalError):
            mysql_error = e
        elif isinstance(e, StatementError) and isinstance(
            e.orig, _mysql_exceptions.OperationalError
        ):
            mysql_error = e.orig

        if mysql_error:
            for msg in TRANSIENT_MYSQL_MESSAGES:
                if msg in mysql_error.message:
                    is_transient = True

        if is_transient:
            occurrences[0] += 1
            if occurrences[0] < 20:
                return
        else:
            occurrences[0] = 1

        if account_id:
            try:
                with session_scope(account_id) as db_session:
                    account = db_session.query(Account).get(account_id)
                    sync_error = account.sync_error
                    if not sync_error or isinstance(sync_error, basestring):
                        account.update_sync_error(e)
                        db_session.commit()
            except:
                log.error(
                    "Error saving sync_error to account object",
                    account_id=account_id,
                    **create_error_log_context(sys.exc_info())
                )

        log_uncaught_errors(
            logger, account_id=account_id, provider=provider, occurrences=occurrences[0]
        )
Esempio n. 3
0
    def callback(e):
        is_transient = isinstance(e, TRANSIENT_NETWORK_ERRS)
        mysql_error = None

        log = logger or get_logger()

        if isinstance(e, _mysql_exceptions.OperationalError):
            mysql_error = e
        elif isinstance(e, StatementError) and isinstance(e.orig, _mysql_exceptions.OperationalError):
            mysql_error = e.orig

        if mysql_error:
            for msg in TRANSIENT_MYSQL_MESSAGES:
                if msg in mysql_error.message:
                    is_transient = True

        if is_transient:
            occurrences[0] += 1
            if occurrences[0] < 20:
                return
        else:
            occurrences[0] = 1

        if account_id:
            try:
                with session_scope(account_id) as db_session:
                    account = db_session.query(Account).get(account_id)
                    sync_error = account.sync_error
                    if not sync_error or isinstance(sync_error, basestring):
                        account.update_sync_error(e)
                        db_session.commit()
            except:
                log.error(
                    "Error saving sync_error to account object",
                    account_id=account_id,
                    **create_error_log_context(sys.exc_info())
                )

        log_uncaught_errors(logger, account_id=account_id, provider=provider, occurrences=occurrences[0])
Esempio n. 4
0
    def callback(e):
        if isinstance(e, TRANSIENT_NETWORK_ERRS):
            occurrences[0] += 1
            if occurrences[0] < 20:
                return
        else:
            occurrences[0] = 1

        if account_id:
            try:
                with session_scope(account_id) as db_session:
                    account = db_session.query(Account).get(account_id)
                    sync_error = account.sync_error
                    if not sync_error or isinstance(sync_error, basestring):
                        account.update_sync_error(e)
                        db_session.commit()
            except:
                logger.error('Error saving sync_error to account object',
                             account_id=account_id,
                             **create_error_log_context(sys.exc_info()))

        log_uncaught_errors(logger, account_id=account_id, provider=provider,
                            occurrences=occurrences[0])