Last active
August 29, 2015 14:20
-
-
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!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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