##// END OF EJS Templates
Only draw remote tracebacks for IPython.parallel remote exceptions
MinRK -
Show More
@@ -84,6 +84,11 b' from IPython.utils.traitlets import (Integer, CBool, CaselessStrEnum, Enum,'
84 84 from IPython.utils.warn import warn, error
85 85 import IPython.core.hooks
86 86
87 try:
88 from IPython.parallel.error import RemoteError
89 except ImportError:
90 class RemoteError(Exception): pass
91
87 92 #-----------------------------------------------------------------------------
88 93 # Globals
89 94 #-----------------------------------------------------------------------------
@@ -1711,6 +1716,10 b' class InteractiveShell(SingletonConfigurable):'
1711 1716 self.showsyntaxerror(filename)
1712 1717 elif etype is UsageError:
1713 1718 self.write_err("UsageError: %s" % value)
1719 elif issubclass(etype, RemoteError):
1720 # IPython.parallel remote exceptions.
1721 # Draw the remote traceback, not the local one.
1722 self._showtraceback(etype, value, value.render_traceback())
1714 1723 else:
1715 1724 if exception_only:
1716 1725 stb = ['An exception has occurred, use %tb to see '
@@ -188,11 +188,17 b' class RemoteError(KernelError):'
188 188 return "<Remote[%s]:%s(%s)>"%(engineid, self.ename, self.evalue)
189 189
190 190 def __str__(self):
191 sig = "%s(%s)"%(self.ename, self.evalue)
192 if self.traceback:
193 return sig + '\n' + self.traceback
194 else:
195 return sig
191 return "%s(%s)" % (self.ename, self.evalue)
192
193 def render_traceback(self):
194 """render traceback to a list of lines"""
195 return (self.traceback or "No traceback available").splitlines()
196
197 def print_traceback(self, excid=None):
198 """print my traceback"""
199 print('\n'.join(self.render_traceback()))
200
201
196 202
197 203
198 204 class TaskRejectError(KernelError):
@@ -244,20 +250,27 b' class CompositeError(RemoteError):'
244 250 def __repr__(self):
245 251 return "CompositeError(%i)"%len(self.elist)
246 252
247 def print_tracebacks(self, excid=None):
253 def render_traceback(self, excid=None):
254 """render one or all of my tracebacks to a list of lines"""
255 lines = []
248 256 if excid is None:
249 257 for (en,ev,etb,ei) in self.elist:
250 print (self._get_engine_str(ei))
251 print (etb or 'No traceback available')
252 print ()
258 lines.append(self._get_engine_str(ei))
259 lines.extend((etb or 'No traceback available').splitlines())
260 lines.append('')
253 261 else:
254 262 try:
255 263 en,ev,etb,ei = self.elist[excid]
256 264 except:
257 265 raise IndexError("an exception with index %i does not exist"%excid)
258 266 else:
259 print (self._get_engine_str(ei))
260 print (etb or 'No traceback available')
267 lines.append(self._get_engine_str(ei))
268 lines.extend((etb or 'No traceback available').splitlines())
269
270 return lines
271
272 def print_traceback(self, excid=None):
273 print('\n'.join(self.render_traceback(excid)))
261 274
262 275 def raise_exception(self, excid=0):
263 276 try:
General Comments 0
You need to be logged in to leave comments. Login now