Thread: Re: [Sqlalchemy-tickets] [sqlalchemy] #2703: safely re-raise exceptions with coroutine framework
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2013-04-12 14:42:31
|
#2703: safely re-raise exceptions with coroutine framework ---------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: new Priority: medium | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: | Keywords: Progress State: in queue | ---------------------------+---------------------------------- Changes (by zzzeek): * status_field: needs review => in queue Comment: I'd like to see if this can be placed into a contextmanager function so that we aren't duplicating code like that in several places. using a common context manager also means we could theoretically vary how this case is handled based on up-front configuration. -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:1> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |
From: sqlalchemy <mi...@zz...> - 2013-04-14 23:08:52
|
#2703: safely re-raise exceptions with coroutine framework ---------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: new Priority: high | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: | Keywords: Progress State: in queue | ---------------------------+---------------------------------- Changes (by zzzeek): * priority: medium => high -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:2> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |
From: sqlalchemy <mi...@zz...> - 2013-04-15 15:10:59
|
#2703: safely re-raise exceptions with coroutine framework ---------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: new Priority: high | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: | Keywords: Progress State: in queue | ---------------------------+---------------------------------- Comment (by layz): I submited a new patch with a contextmanager class just now. Is that OK? -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:3> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |
From: sqlalchemy <mi...@zz...> - 2013-04-15 15:53:38
|
#2703: safely re-raise exceptions with coroutine framework ---------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: new Priority: high | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: | Keywords: Progress State: in queue | ---------------------------+---------------------------------- Comment (by zzzeek): OK thanks, I was working on a patch last night that includes some other things, including a new approach to py2k/3k exceptions. _handle_dbapi_exception() does an "autorollback" too, so the sys.exc_info() in there also needs to be stored, and I was thinking of having sys.exc_info() be passed into _handle_dbapi_exception() from the outside but i still need to play with it a bit. -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:4> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |
From: sqlalchemy <mi...@zz...> - 2013-04-15 18:58:26
|
#2703: safely re-raise exceptions with coroutine framework ---------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: new Priority: high | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: | Keywords: Progress State: in queue | ---------------------------+---------------------------------- Comment (by zzzeek): check out the attached patch, make sure it works for you, I still need to ensure the Py3k "cause" handling works the way I'd like. -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:5> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |
From: sqlalchemy <mi...@zz...> - 2013-04-16 01:21:19
|
#2703: safely re-raise exceptions with coroutine framework ---------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: new Priority: high | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: | Keywords: Progress State: in queue | ---------------------------+---------------------------------- Comment (by layz): Hi zzzeek, It's better to remove the reference of traceback object manually before reraise it(traceback object keep a large circular reference, there is some memory problem with a long-running program). {{{ def __exit__(self, type_, value, traceback): if type_ is None: exc_type, exc_value, exc_tb = self._exc_info self._exc_info = None # remove the reference of traceback object manually compat.reraise(exc_type, exc_value, exc_tb) else: self._exc_info = None # remove the reference of traceback object manually compat.reraise(type_, value, traceback) }}} The following is document of sys.exc_info: Warning Assigning the traceback return value to a local variable in a function that is handling an exception will cause a circular reference. This will prevent anything referenced by a local variable in the same function or by the traceback from being garbage collected. Since most functions don’t need access to the traceback, the best solution is to use something like exctype, value = sys.exc_info()[:2] to extract only the exception type and value. If you do need the traceback, make sure to delete it after use (best done with a try ... finally statement) or to call exc_info() in a function that does not itself handle an exception. cheers, layz -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:6> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |
From: sqlalchemy <mi...@zz...> - 2013-04-18 15:06:52
|
#2703: safely re-raise exceptions with coroutine framework -----------------------------------+---------------------------------- Reporter: layz | Owner: zzzeek Type: defect | Status: closed Priority: high | Milestone: 0.8.xx Component: orm | Severity: minor - half an hour Resolution: fixed | Keywords: Progress State: completed/closed | -----------------------------------+---------------------------------- Changes (by zzzeek): * status: new => closed * resolution: => fixed * status_field: in queue => completed/closed Comment: rfc1816232c92, and I added the setting _exc_info to None in r3c2e274d9563 -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2703#comment:7> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |