Show More
@@ -395,6 +395,7 b' class EngineService(object, service.Service):' | |||||
395 |
|
395 | |||
396 | return d |
|
396 | return d | |
397 |
|
397 | |||
|
398 | ||||
398 | # The IEngine methods. See the interface for documentation. |
|
399 | # The IEngine methods. See the interface for documentation. | |
399 |
|
400 | |||
400 | def execute(self, lines): |
|
401 | def execute(self, lines): | |
@@ -862,6 +863,30 b' class ThreadedEngineService(EngineService):' | |||||
862 | def __init__(self, shellClass=Interpreter, mpi=None): |
|
863 | def __init__(self, shellClass=Interpreter, mpi=None): | |
863 | EngineService.__init__(self, shellClass, mpi) |
|
864 | EngineService.__init__(self, shellClass, mpi) | |
864 |
|
865 | |||
|
866 | def wrapped_execute(self, msg, lines): | |||
|
867 | """Wrap self.shell.execute to add extra information to tracebacks""" | |||
|
868 | ||||
|
869 | try: | |||
|
870 | result = self.shell.execute(lines) | |||
|
871 | except Exception,e: | |||
|
872 | # This gives the following: | |||
|
873 | # et=exception class | |||
|
874 | # ev=exception class instance | |||
|
875 | # tb=traceback object | |||
|
876 | et,ev,tb = sys.exc_info() | |||
|
877 | # This call adds attributes to the exception value | |||
|
878 | et,ev,tb = self.shell.formatTraceback(et,ev,tb,msg) | |||
|
879 | # Add another attribute | |||
|
880 | ||||
|
881 | # Create a new exception with the new attributes | |||
|
882 | e = et(ev._ipython_traceback_text) | |||
|
883 | e._ipython_engine_info = msg | |||
|
884 | ||||
|
885 | # Re-raise | |||
|
886 | raise e | |||
|
887 | ||||
|
888 | return result | |||
|
889 | ||||
865 |
|
890 | |||
866 | def execute(self, lines): |
|
891 | def execute(self, lines): | |
867 | # Only import this if we are going to use this class |
|
892 | # Only import this if we are going to use this class | |
@@ -871,6 +896,6 b' class ThreadedEngineService(EngineService):' | |||||
871 | 'method':'execute', |
|
896 | 'method':'execute', | |
872 | 'args':[lines]} |
|
897 | 'args':[lines]} | |
873 |
|
898 | |||
874 |
d = threads.deferToThread(self. |
|
899 | d = threads.deferToThread(self.wrapped_execute, msg, lines) | |
875 | d.addCallback(self.addIDToResult) |
|
900 | d.addCallback(self.addIDToResult) | |
876 | return d |
|
901 | return d |
General Comments 0
You need to be logged in to leave comments.
Login now