##// END OF EJS Templates
ready for wrapped_execute
Barry Wark -
Show More
@@ -45,9 +45,9 b' from IPython.frontend.frontendbase import AsyncFrontEndBase'
45 45 from twisted.internet.threads import blockingCallFromThread
46 46 from twisted.python.failure import Failure
47 47
48 #------------------------------------------------------------------------------
48 #-----------------------------------------------------------------------------
49 49 # Classes to implement the Cocoa frontend
50 #------------------------------------------------------------------------------
50 #-----------------------------------------------------------------------------
51 51
52 52 # TODO:
53 53 # 1. use MultiEngineClient and out-of-process engine rather than
@@ -61,39 +61,13 b' class AutoreleasePoolWrappedThreadedEngineService(ThreadedEngineService):'
61 61 """wrapped_execute"""
62 62 try:
63 63 p = NSAutoreleasePool.alloc().init()
64 result = self.shell.execute(lines)
65 except Exception,e:
66 # This gives the following:
67 # et=exception class
68 # ev=exception class instance
69 # tb=traceback object
70 et,ev,tb = sys.exc_info()
71 # This call adds attributes to the exception value
72 et,ev,tb = self.shell.formatTraceback(et,ev,tb,msg)
73 # Add another attribute
74
75 # Create a new exception with the new attributes
76 e = et(ev._ipython_traceback_text)
77 e._ipython_engine_info = msg
78
79 # Re-raise
80 raise e
64 result = super(AutoreleasePoolWrappedThreadedEngineService,
65 self).wrapped_execute(msg, lines)
81 66 finally:
82 67 p.drain()
83 68
84 69 return result
85 70
86 def execute(self, lines):
87 # Only import this if we are going to use this class
88 from twisted.internet import threads
89
90 msg = {'engineid':self.id,
91 'method':'execute',
92 'args':[lines]}
93
94 d = threads.deferToThread(self.wrapped_execute, msg, lines)
95 d.addCallback(self.addIDToResult)
96 return d
97 71
98 72
99 73 class IPythonCocoaController(NSObject, AsyncFrontEndBase):
@@ -37,11 +37,6 b' from IPython.kernel.core.history import FrontEndHistory'
37 37 from IPython.kernel.core.util import Bunch
38 38 from IPython.kernel.engineservice import IEngineCore
39 39
40 try:
41 from twisted.python.failure import Failure
42 except ImportError:
43 #Twisted not available
44 Failure = Exception
45 40
46 41 ##############################################################################
47 42 # TEMPORARY!!! fake configuration, while we decide whether to use tconfig or
@@ -387,6 +382,7 b' class AsyncFrontEndBase(FrontEndBase):'
387 382 """
388 383
389 384 if(not self.is_complete(block)):
385 from twisted.python.failure import Failure
390 386 return Failure(Exception("Block is not compilable"))
391 387
392 388 if(blockID == None):
General Comments 0
You need to be logged in to leave comments. Login now