當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。