Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parts of traceback is lost when reraising exceptions #10

Closed
jodal opened this issue Aug 5, 2012 · 1 comment
Closed

Parts of traceback is lost when reraising exceptions #10

jodal opened this issue Aug 5, 2012 · 1 comment
Assignees
Labels

Comments

@jodal
Copy link
Owner

jodal commented Aug 5, 2012

This issue was reported by @adamcik at IRC after review of the Pykka source code.

At https://github.com/jodal/pykka/blob/master/pykka/gevent.py#L37 a gevent.Timeout exceptions is reraised wrapped in a pykka.Timeout exception. This reraise does not keep the traceback of the original exception.

At https://github.com/jodal/pykka/blob/master/pykka/future.py#L93 a exception thrown in a ThreadingActor is reraised in the thread of a consumer of a ThreadingFuture. This reraise does not keep the traceback of the original exception.

The exceptions should be reraised using the three-argument raise syntax:

raise exc_class, exc_instance, traceback

E.g.:

raise _Timeout, _Timeout(e), sys.exc_info()[2]

In cases where the exception is thrown in one thread and reraised in another thread, the first thread must make sure to pass on both the exception object and the traceback, found at sys.exc_info()[2].

@ghost ghost assigned jodal Aug 5, 2012
@adamcik
Copy link

adamcik commented Aug 5, 2012

I would suggest changing the future.py code to pass around (value, exc_info) instead of just value. This seems more robust than assuming that any value that is an exception should be raised. Looking at other code bases that handle this type of re-raise issues there seem to be some gotchas here with respect to circular loops created by data in the traceback that you will probably have to avoid.

@jodal jodal closed this as completed in 22f8d25 Aug 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants