예제 #1
0
def test_safe_format_exception():
    try:
        raise ReallyVerboseError()
    except ReallyVerboseError:
        # Check that the stdlib exception formatting would be large
        assert (len('\t'.join(traceback.format_exception(*sys.exc_info()))) >
                2 * MAX_EXCEPTION_LENGTH)
        exc = safe_format_exception(*sys.exc_info())
        # And check that the resulting string is reasonably-sized.
        assert len(exc) < 2 * MAX_EXCEPTION_LENGTH
예제 #2
0
def test_safe_format_exception():
    try:
        raise ReallyVerboseError()
    except ReallyVerboseError:
        # Check that the stdlib exception formatting would be large
        assert (len('\t'.join(traceback.format_exception(*sys.exc_info()))) >
                2 * MAX_EXCEPTION_LENGTH)
        exc = safe_format_exception(*sys.exc_info())
        # And check that the resulting string is reasonably-sized.
        assert len(exc) < 2 * MAX_EXCEPTION_LENGTH
예제 #3
0
def report_killed(account_id, folder_name=None):
    error = safe_format_exception(*sys.exc_info())

    with session_scope() as db_session:
        account = db_session.query(Account).get(account_id)

        # MailSyncMonitor for account
        if folder_name is None:
            account.kill_sync(error)
        else:
            # FolderSyncMonitor for account's folder
            for f in account.foldersyncstatuses:
                if f.folder.name == folder_name:
                    f.update_metrics(dict(run_state="killed", sync_end_time=datetime.utcnow(), sync_error=error))

        db_session.commit()
예제 #4
0
def report_killed(account_id, folder_name=None):
    error = safe_format_exception(*sys.exc_info())

    with session_scope() as db_session:
        account = db_session.query(Account).get(account_id)

        # MailSyncMonitor for account
        if folder_name is None:
            account.kill_sync(error)
        else:
            # FolderSyncMonitor for account's folder
            statuses = account.foldersyncstatuses
            for f in statuses:
                if f.folder.name == folder_name:
                    f.kill_sync(error)

            if all([f.is_killed for f in statuses]):
                account.kill_sync()

        db_session.commit()
예제 #5
0
def report_killed(account_id, folder_name=None):
    error = safe_format_exception(*sys.exc_info())

    with session_scope() as db_session:
        account = db_session.query(Account).get(account_id)

        # MailSyncMonitor for account
        if folder_name is None:
            account.kill_sync(error)
        else:
            # FolderSyncMonitor for account's folder
            statuses = account.foldersyncstatuses
            for f in statuses:
                if f.folder.name == folder_name:
                    f.kill_sync(error)

            if all([f.is_killed for f in statuses]):
                account.kill_sync()

        db_session.commit()