当前位置: 首页>>代码示例>>Python>>正文


Python util.raise_exc_info方法代码示例

本文整理汇总了Python中tornado.util.raise_exc_info方法的典型用法代码示例。如果您正苦于以下问题:Python util.raise_exc_info方法的具体用法?Python util.raise_exc_info怎么用?Python util.raise_exc_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.util的用法示例。


在下文中一共展示了util.raise_exc_info方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_two_arg_exception

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def test_two_arg_exception(self):
        # This test would fail on python 3 if raise_exc_info were simply
        # a three-argument raise statement, because TwoArgException
        # doesn't have a "copy constructor"
        class TwoArgException(Exception):
            def __init__(self, a, b):
                super(TwoArgException, self).__init__()
                self.a, self.b = a, b

        try:
            raise TwoArgException(1, 2)
        except TwoArgException:
            exc_info = sys.exc_info()
        try:
            raise_exc_info(exc_info)
            self.fail("didn't get expected exception")
        except TwoArgException as e:
            self.assertIs(e, exc_info[1]) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:util_test.py

示例2: test_two_arg_exception

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def test_two_arg_exception(self):
        # This test would fail on python 3 if raise_exc_info were simply
        # a three-argument raise statement, because TwoArgException
        # doesn't have a "copy constructor"
        class TwoArgException(Exception):
            def __init__(self, a, b):
                super(TwoArgException, self).__init__()
                self.a, self.b = a, b

        try:
            raise TwoArgException(1, 2)
        except TwoArgException:
            exc_info = sys.exc_info()
        try:
            raise_exc_info(exc_info)
            self.fail("didn't get expected exception")
        except TwoArgException, e:
            self.assertTrue(e is exc_info[1]) 
开发者ID:omererdem,项目名称:honeything,代码行数:20,代码来源:util_test.py

示例3: raise_exc_info

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def raise_exc_info(exc_info):
        try:
            raise exc_info[1].with_traceback(exc_info[2])
        finally:
            exc_info = None 
开发者ID:snower,项目名称:TorMySQL,代码行数:7,代码来源:helpers.py

示例4: commit

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def commit(self):
            self._ensure_conn()
            try:
                yield self._connection.commit()
            except:
                exc_info = sys.exc_info()
                self._connection.close(True)
                raise_exc_info(exc_info)
            else:
                self._connection.close()
            finally:
                self._connection = None 
开发者ID:snower,项目名称:TorMySQL,代码行数:14,代码来源:helpers.py

示例5: rollback

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def rollback(self):
            self._ensure_conn()
            try:
                yield self._connection.rollback()
            except:
                exc_info = sys.exc_info()
                self._connection.close(True)
                raise_exc_info(exc_info)
            else:
                self._connection.close()
            finally:
                self._connection = None 
开发者ID:snower,项目名称:TorMySQL,代码行数:14,代码来源:helpers.py

示例6: execute

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def execute(self, query, params=None, cursor_cls=None):
            with (yield self.Connection()) as connection:
                cursor = connection.cursor(cursor_cls)
                try:
                    yield cursor.execute(query, params)
                    if not connection._connection.autocommit_mode:
                        yield connection.commit()
                except:
                    exc_info = sys.exc_info()
                    if not connection._connection.autocommit_mode:
                        yield connection.rollback()
                    raise_exc_info(exc_info)
                finally:
                    yield cursor.close()
            raise Return(cursor) 
开发者ID:snower,项目名称:TorMySQL,代码行数:17,代码来源:helpers.py

示例7: executemany

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import raise_exc_info [as 别名]
def executemany(self, query, params=None, cursor_cls=None):
            with (yield self.Connection()) as connection:
                cursor = connection.cursor(cursor_cls)
                try:
                    yield cursor.executemany(query, params)
                    if not connection._connection.autocommit_mode:
                        yield connection.commit()
                except:
                    exc_info = sys.exc_info()
                    if not connection._connection.autocommit_mode:
                        yield connection.rollback()
                    raise_exc_info(exc_info)
                finally:
                    yield cursor.close()
            raise Return(cursor) 
开发者ID:snower,项目名称:TorMySQL,代码行数:17,代码来源:helpers.py


注:本文中的tornado.util.raise_exc_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。