Skip to content

Instantly share code, notes, and snippets.

@soldni
Last active August 29, 2015 14:20
Show Gist options
  • Save soldni/5b0bf47a7c08c678bf18 to your computer and use it in GitHub Desktop.
Save soldni/5b0bf47a7c08c678bf18 to your computer and use it in GitHub Desktop.
Make sure that your multiprocessing pool workers report their full traceback when crashing!
import sys
import traceback
from functools import wraps
def error_wrapper_pool(method):
""" Make sure that your multiprocessing pool workers report
their full traceback when crashing!
"""
@wraps(method)
def wrapper(*args, **kwargs):
try:
method(*args, **kwargs)
except:
trace = traceback.format_exception(*sys.exc_info())
raise RuntimeError(''.join(trace))
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment