##// END OF EJS Templates
Fix bug where traceback wasn't being correctly stored in remote tasks....
Fernando Perez -
Show More
@@ -390,7 +390,7 b' class EngineService(object, service.Service):'
390 et,ev,tb = self.shell.format_traceback(et,ev,tb,msg)
390 et,ev,tb = self.shell.format_traceback(et,ev,tb,msg)
391 # Add another attribute
391 # Add another attribute
392 ev._ipython_engine_info = msg
392 ev._ipython_engine_info = msg
393 f = failure.Failure(ev,et,None)
393 f = failure.Failure(ev,et,tb)
394 d.errback(f)
394 d.errback(f)
395 else:
395 else:
396 d.callback(result)
396 d.callback(result)
@@ -185,3 +185,63 b' class ITaskControllerTestCase(TaskTestBase):'
185 d.addCallback(lambda _: self.tc.get_task_result(0, block=True))
185 d.addCallback(lambda _: self.tc.get_task_result(0, block=True))
186 d.addErrback(lambda f: self.assertRaises(IndexError, f.raiseException))
186 d.addErrback(lambda f: self.assertRaises(IndexError, f.raiseException))
187 return d
187 return d
188
189 def get_traceback_frames(self, result):
190 """Execute a failing string as a task and return stack frame strings.
191
192 This lets us check that the returned exceptions contain as many stack
193 frames as the user expects from his code.
194
195 Parameters
196 ----------
197 d : deferred
198
199 src : string
200 Code to be executed, should fail."""
201 # This gets Twisted's short-format traceback and picks the info for
202 # frames that actually belong to user code.
203 return result.failure.getBriefTraceback().split('\n<string>:')[1:]
204
205
206 def check_traceback(self, cmd, nframes, exception=IOError):
207 """Ensure that we have a traceback object in task failures."""
208
209 self.addEngine(1)
210 t1 = task.StringTask(cmd)
211 d = self.tc.run(t1)
212 d.addCallback(self.tc.get_task_result, block=True)
213 # Sanity check, that the right exception is raised
214 d.addCallback(lambda r: self.assertRaises(exception, r.raise_exception))
215 # Rerun the same task, this time we check for the traceback to have the
216 # right number of frames
217 d.addCallback(lambda r: self.tc.run(t1))
218 d.addCallback(self.tc.get_task_result, block=True)
219 d.addCallback(self.get_traceback_frames)
220 d.addCallback(lambda frames: self.assertEquals(len(frames), nframes))
221 return d
222
223 # Check traceback structure with 2 and 4 frame-deep stacks
224 def test_traceback(self):
225 cmd = """
226 def fail():
227 raise IOError('failure test')
228
229 result = fail()
230 """
231 return self.check_traceback(cmd, 2)
232
233
234 def test_traceback2(self):
235 cmd = """
236 def boom():
237 raise IOError('failure test')
238
239 def crash():
240 boom()
241
242 def fail():
243 crash()
244
245 result = fail()
246 """
247 return self.check_traceback(cmd, 4)
General Comments 0
You need to be logged in to leave comments. Login now