Skip to content

Instantly share code, notes, and snippets.

@erikrose
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikrose/154dd6c944ca7e0836ae to your computer and use it in GitHub Desktop.
Save erikrose/154dd6c944ca7e0836ae to your computer and use it in GitHub Desktop.
def full_traceback(callable, *args, **kwargs):
"""Work around the wretched exception reporting of concurrent.futures.
Futures generally gives no access to the traceback of the task; you get
only a traceback into the guts of futures, plus the description line of
the task's traceback. We jam the full traceback of any exception that
occurs into the message of the exception: disgusting but informative.
"""
try:
return callable(*args, **kwargs)
except Exception:
raise Exception(format_exc())
@erikrose
Copy link
Author

Example use:

pool.submit(some_function, some, args)

…becomes…

pool.submit(full_traceback, some_function, some, args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment