##// END OF EJS Templates
More work addressing review comments for Fernando's branch....
More work addressing review comments for Fernando's branch. * :mod:`IPython.testing.globalipapp` now directly creates a :class:`~IPython.core.iplib.InteractiveShell` instance by passing it a configuration object, rather than creating an IPython application. * Updated everything in :mod:`IPython.frontend` and :mod:`IPython.gui` to use raw :class:`~IPython.core.iplib.InteractiveShell directly rather than creating an IPython application. * Updated the IPython sphinx extension to use raw :class:`~IPython.core.iplib.InteractiveShell directly rather than creating an IPython application. * Removed code from :mod:`IPython.extensions.pretty` that called :func:`get_ipython` (r1271). * Addressed comment on (r1284) about holding refs to deferreds in :mod:`IPython.kernel.ipclusterapp`. * Removed :mod:`IPython.kernel` from list of modules tested by nose in :mod:`IPython.testing.iptest`. (r1318)

File last commit:

r2133:fcf58986
r2499:58bf4021
Show More
asyncfrontendbase.py
82 lines | 2.8 KiB | text/x-python | PythonLexer
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355 """
Base front end class for all async frontends.
"""
__docformat__ = "restructuredtext en"
Fernando Perez
Fixes so the test suite runs when Twisted is not available....
r2133 # Tell nose to skip this module
__test__ = {}
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355 #-------------------------------------------------------------------------------
# Copyright (C) 2008 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------
Fernando Perez
Fixes so the test suite runs when Twisted is not available....
r2133 # Third-party
from twisted.python.failure import Failure
from zope.interface import implements, classProvides
# From IPython
Brian Granger
Fixing misc testing related things.
r1960 from IPython.external import guid
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355
Fernando Perez
Fixes so the test suite runs when Twisted is not available....
r2133 from IPython.frontend.frontendbase import (FrontEndBase, IFrontEnd,
IFrontEndFactory)
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355 from IPython.kernel.core.history import FrontEndHistory
Brian Granger
Fixed another bug related to missing dependencies in tests.
r1558 from IPython.kernel.engineservice import IEngineCore
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355
Fernando Perez
Fixes so the test suite runs when Twisted is not available....
r2133 #-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355
class AsyncFrontEndBase(FrontEndBase):
"""
Overrides FrontEndBase to wrap execute in a deferred result.
All callbacks are made as callbacks on the deferred result.
"""
implements(IFrontEnd)
classProvides(IFrontEndFactory)
def __init__(self, engine=None, history=None):
assert(engine==None or IEngineCore.providedBy(engine))
self.engine = IEngineCore(engine)
if history is None:
self.history = FrontEndHistory(input_cache=[''])
else:
self.history = history
Fernando Perez
Fixes so the test suite runs when Twisted is not available....
r2133
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355 def execute(self, block, blockID=None):
"""Execute the block and return the deferred result.
Parameters:
block : {str, AST}
blockID : any
Caller may provide an ID to identify this block.
result['blockID'] := blockID
Result:
Deferred result of self.interpreter.execute
"""
if(not self.is_complete(block)):
return Failure(Exception("Block is not compilable"))
if(blockID == None):
Gael Varoquaux
Replace all use of the ast module with the codeop module, and all use of...
r1710 blockID = guid.generate()
Gael Varoquaux
Split the frontend base class in different files and add a base class...
r1355
d = self.engine.execute(block)
d.addCallback(self._add_history, block=block)
d.addCallbacks(self._add_block_id_for_result,
errback=self._add_block_id_for_failure,
callbackArgs=(blockID,),
errbackArgs=(blockID,))
d.addBoth(self.update_cell_prompt, blockID=blockID)
d.addCallbacks(self.render_result,
errback=self.render_error)
return d