python类errorcodes()的实例源码

smartdb.py 文件源码 项目:enjoliver 作者: JulienBalestra 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def cockroach_transaction(f):
    def run_transaction(caller):
        while True:
            with MONITOR_COCKROACHDB.observe_transaction(caller):
                try:
                    return f()
                except DatabaseError as e:
                    if not isinstance(e.orig, psycopg2.OperationalError) and \
                            not e.orig.pgcode == psycopg2.errorcodes.SERIALIZATION_FAILURE:
                        raise
                    MONITOR_COCKROACHDB.cockroach_retry_count.labels(caller).inc()

    return run_transaction
testutils.py 文件源码 项目:PyEloqua-Examples 作者: colemanja91 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def skip_if_no_superuser(f):
    """Skip a test if the database user running the test is not a superuser"""
    @wraps(f)
    def skip_if_no_superuser_(self):
        from psycopg2 import ProgrammingError
        try:
            return f(self)
        except ProgrammingError as e:
            import psycopg2.errorcodes
            if e.pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE:
                self.skipTest("skipped because not superuser")
            else:
                raise

    return skip_if_no_superuser_
testutils.py 文件源码 项目:flask 作者: bobohope 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def skip_if_no_superuser(f):
    """Skip a test if the database user running the test is not a superuser"""
    @wraps(f)
    def skip_if_no_superuser_(self):
        from psycopg2 import ProgrammingError
        try:
            return f(self)
        except ProgrammingError, e:
            import psycopg2.errorcodes
            if e.pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE:
                self.skipTest("skipped because not superuser")
            else:
                raise

    return skip_if_no_superuser_


问题


面经


文章

微信
公众号

扫码关注公众号