Show More
@@ -45,9 +45,9 b' from IPython.frontend.frontendbase import AsyncFrontEndBase' | |||||
45 | from twisted.internet.threads import blockingCallFromThread |
|
45 | from twisted.internet.threads import blockingCallFromThread | |
46 | from twisted.python.failure import Failure |
|
46 | from twisted.python.failure import Failure | |
47 |
|
47 | |||
48 |
#----------------------------------------------------------------------------- |
|
48 | #----------------------------------------------------------------------------- | |
49 | # Classes to implement the Cocoa frontend |
|
49 | # Classes to implement the Cocoa frontend | |
50 |
#----------------------------------------------------------------------------- |
|
50 | #----------------------------------------------------------------------------- | |
51 |
|
51 | |||
52 | # TODO: |
|
52 | # TODO: | |
53 | # 1. use MultiEngineClient and out-of-process engine rather than |
|
53 | # 1. use MultiEngineClient and out-of-process engine rather than | |
@@ -61,39 +61,13 b' class AutoreleasePoolWrappedThreadedEngineService(ThreadedEngineService):' | |||||
61 | """wrapped_execute""" |
|
61 | """wrapped_execute""" | |
62 | try: |
|
62 | try: | |
63 | p = NSAutoreleasePool.alloc().init() |
|
63 | p = NSAutoreleasePool.alloc().init() | |
64 | result = self.shell.execute(lines) |
|
64 | result = super(AutoreleasePoolWrappedThreadedEngineService, | |
65 | except Exception,e: |
|
65 | self).wrapped_execute(msg, lines) | |
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 |
|
|||
81 | finally: |
|
66 | finally: | |
82 | p.drain() |
|
67 | p.drain() | |
83 |
|
68 | |||
84 | return result |
|
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 | class IPythonCocoaController(NSObject, AsyncFrontEndBase): |
|
73 | class IPythonCocoaController(NSObject, AsyncFrontEndBase): |
@@ -37,11 +37,6 b' from IPython.kernel.core.history import FrontEndHistory' | |||||
37 | from IPython.kernel.core.util import Bunch |
|
37 | from IPython.kernel.core.util import Bunch | |
38 | from IPython.kernel.engineservice import IEngineCore |
|
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 | # TEMPORARY!!! fake configuration, while we decide whether to use tconfig or |
|
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 | if(not self.is_complete(block)): |
|
384 | if(not self.is_complete(block)): | |
|
385 | from twisted.python.failure import Failure | |||
390 | return Failure(Exception("Block is not compilable")) |
|
386 | return Failure(Exception("Block is not compilable")) | |
391 |
|
387 | |||
392 | if(blockID == None): |
|
388 | if(blockID == None): |
General Comments 0
You need to be logged in to leave comments.
Login now