本文整理汇总了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])
示例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])
示例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
示例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
示例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
示例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)
示例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)