Python tornado.util.raise_exc_info() Examples
The following are 11
code examples of tornado.util.raise_exc_info().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.util
, or try the search function
.
Example #1
Source File: util_test.py From tornado-zh with MIT License | 6 votes |
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])
Example #2
Source File: util_test.py From tornado-zh with MIT License | 6 votes |
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])
Example #3
Source File: util_test.py From viewfinder with Apache License 2.0 | 6 votes |
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])
Example #4
Source File: util_test.py From viewfinder with Apache License 2.0 | 6 votes |
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])
Example #5
Source File: util_test.py From honeything with GNU General Public License v3.0 | 6 votes |
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])
Example #6
Source File: util_test.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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])
Example #7
Source File: helpers.py From TorMySQL with MIT License | 5 votes |
def raise_exc_info(exc_info): try: raise exc_info[1].with_traceback(exc_info[2]) finally: exc_info = None
Example #8
Source File: helpers.py From TorMySQL with MIT License | 5 votes |
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
Example #9
Source File: helpers.py From TorMySQL with MIT License | 5 votes |
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
Example #10
Source File: helpers.py From TorMySQL with MIT License | 5 votes |
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)
Example #11
Source File: helpers.py From TorMySQL with MIT License | 5 votes |
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)