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

Use RemoteTraceback to output the cause of an exception when it is thrown #17

Merged
merged 2 commits into from
Nov 23, 2017

Conversation

stevenheidel
Copy link
Contributor

We're using Pebble and were having difficulty debugging due to the stack trace of the original exception not being shown. The solution I took is the same one that is used in multiprocessing.pool.

Without this change, the information we got by default from an error within a process was something like:
AssertionError

Now we get the full stacktrace:

Traceback (most recent call last):
  File "/Users/steven/.pyenv/versions/3.6.3/lib/python3.6/concurrent/futures/process.py", line 175, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/Users/steven/workspace/project/low_level_translation.py", line 237, in translate_to_settings
    settings = generate_settings(input)
  File "/Users/steven/workspace/project/low_level_translation.py", line 119, in generate_settings
    assert input.direction == output.direction
AssertionError

@noxdafox
Copy link
Owner

Thanks for your contribution!

The remote traceback is appended to the exception but it's not documented and I personally don't like it myself. I was planning to refactor it but it was low in my TODO list.

Your solution only covers the ProcessPool use case and not all the use cases (ThreadPool, decorators etc) but it's a good starting point. I will further develop it.

In the meantime, you can access the remote traceback of the error like in this example (check the generic Exception handler).

@noxdafox noxdafox merged commit 1563b7d into noxdafox:master Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants