]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
Don't lose tracebacks of exceptions raised in a greenlet.
authorTommi Virtanen <tv@inktank.com>
Tue, 11 Sep 2012 18:11:39 +0000 (11:11 -0700)
committerTommi Virtanen <tv@inktank.com>
Tue, 11 Sep 2012 18:25:21 +0000 (11:25 -0700)
commit79607eed3ca18c3a99cca9bf614aff8c56b8d462
tree08a0bf7bcdb2c7cb0dc4b364b01f150ee3906097
parentf64cedf4dbb02bbf77558224f49935ab29f79106
Don't lose tracebacks of exceptions raised in a greenlet.

Exception objects don't contain the traceback of where they were
raised from (to avoid cyclic data structures wrecking gc and causing
mem leaks), so the singular "raise obj" form creates a new traceback
from the current execution location, thus losing the original location
of the error.

Gevent explicitly wants to throw away the traceback, to release any
objects the greenlet may still be referring to, closing files,
releasing locks etc. In this case, we think it's safe, so stash the
exception info away in a holder object, and resurrect it on the other
side of the results queue.

http://stackoverflow.com/questions/9268916/how-to-capture-a-traceback-in-gevent

This can be reproduced easily with

from teuthology.parallel import parallel
def f():
    raise RuntimeError("bork")
with parallel() as p:
    p.spawn(f)

and looking at the resulting traceback with and without this change.
teuthology/parallel.py