diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-03 17:28:43 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-03 17:28:43 +0000 |
| commit | 005db2d7d494115c05b68875dcf222a68abc0957 (patch) | |
| tree | c1c48cdbe6696fd418592d80ee66b061bab209e4 /nova/utils.py | |
| parent | 05370d0aa85d0ecb7d51098ca0c42d96777e3a20 (diff) | |
| parent | e2403739d5e866e011ecc45a4d5b20d5e0192997 (diff) | |
| download | nova-005db2d7d494115c05b68875dcf222a68abc0957.tar.gz nova-005db2d7d494115c05b68875dcf222a68abc0957.tar.xz nova-005db2d7d494115c05b68875dcf222a68abc0957.zip | |
Merge "Log original dropped exception when a new exception occurs"
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/nova/utils.py b/nova/utils.py index 9a01a6fb8..655be744d 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -979,21 +979,27 @@ def generate_glance_url(): @contextlib.contextmanager -def original_exception_raised(): - """Run some code, then re-raise the original exception. +def save_and_reraise_exception(): + """Save current exception, run some code and then re-raise. - This is needed because when Eventlet switches greenthreads, it clears the - exception context. This means if exception handler code blocks, we'll lose - the helpful exception traceback information. + In some cases the exception context can be cleared, resulting in None + being attempted to be reraised after an exception handler is run. This + can happen when eventlet switches greenthreads or when running an + exception handler, code raises and catches and exception. In both + cases the exception context will be cleared. To work around this, we save the exception state, run handler code, and - then re-raise the original exception. + then re-raise the original exception. If another exception occurs, the + saved exception is logged and the new exception is reraised. """ type_, value, traceback = sys.exc_info() try: yield - finally: - raise type_, value, traceback + except: + LOG.exception(_('Original exception being dropped'), + exc_info=(type_, value, traceback)) + raise + raise type_, value, traceback def make_dev_path(dev, partition=None, base='/dev'): |
