本文整理匯總了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)