Inheritance diagram for IPython.kernel.engineservice:
A Twisted Service Representation of the IPython core.
The IPython Core exposed to the network is called the Engine. Its representation in Twisted in the EngineService. Interfaces and adapters are used to abstract out the details of the actual network protocol used. The EngineService is an Engine that knows nothing about the actual protocol used.
The EngineService is exposed with various network protocols in modules like:
enginepb.py enginevanilla.py
As of 12/12/06 the classes in this module have been simplified greatly. It was felt that we had over-engineered things. To improve the maintainability of the code we have taken out the ICompleteEngine interface and the completeEngine method that automatically added methods to engines.
Bases: object
A command object that encapslates queued commands.
This class basically keeps track of a command that has been queued in a QueuedEngine. It manages the deferreds and hold the method to be called and the arguments to that method.
Build a new Command object.
When an error has occured, relay it to self.deferred.
When the result is ready, relay it to self.deferred.
Sets the deferred attribute of the Command.
Bases: object, twisted.application.service.Service
Adapt a IPython shell into a IEngine implementing Twisted Service.
Create an EngineService.
shellClass: something that implements IInterpreter or core1 mpi: an mpi module that has rank and size attributes
Call a method of self.shell and wrap any exception.
Return a list of variables names in the users top level namespace.
This used to return a dict of all the keys/repr(values) in the user’s namespace. This was too much info for the ControllerService to handle so it is now just a list of keys.
Bases: IPython.kernel.engineservice.IEngineCore, IPython.kernel.engineservice.IEngineSerialized, IPython.kernel.engineservice.IEngineProperties
The basic engine interface that EngineService will implement.
This exists so it is easy to specify adapters that adapt to and from the API that the basic EngineService implements.
Bases: zope.interface.Interface
The minimal required interface for the IPython Engine.
This interface provides a formal specification of the IPython core. All these methods should return deferreds regardless of what side of a network connection they are on.
In general, this class simply wraps a shell class and wraps its return values as Deferred objects. If the underlying shell class method raises an exception, this class should convert it to a twisted.failure.Failure that will be propagated along the Deferred’s errback chain.
In addition, Failures are aggressive. By this, we mean that if a method is performing multiple actions (like pulling multiple object) if any single one fails, the entire method will fail with that Failure. It is all or nothing.
Bases: IPython.kernel.engineservice.IEngineBase
Interface for adding a queue to an IEngineBase.
This interface extends the IEngineBase interface to add methods for managing the engine’s queue. The implicit details of this interface are that the execution of all methods declared in IEngineBase should appropriately be put through a queue before execution.
All methods should return deferreds.
Bases: zope.interface.Interface
Push/Pull methods that take Serialized objects.
All methods should return deferreds.
Bases: object
Adapt an IEngineBase to an IEngineQueued by wrapping it.
The resulting object will implement IEngineQueued which extends IEngineCore which extends (IEngineBase, IEngineSerialized).
This seems like the best way of handling it, but I am not sure. The other option is to have the various base interfaces be used like mix-in intefaces. The problem I have with this is adpatation is more difficult and complicated because there can be can multiple original and final Interfaces.
Create a QueuedEngine object from an engine
engine: An implementor of IEngineCore and IEngineSerialized keepUpToDate: whether to update the remote status when the
queue is empty. Defaults to False.
Abort current command.
This eats the Failure but first passes it onto the Deferred that the user has.
It also clear out the queue so subsequence commands don’t run.
Clear the queue, but doesn’t cancel the currently running commmand.
Finish currrent command.
Run current command.
Put the result in the history.
Submit command to queue.
Bases: dict
This is a strict copying dictionary for use as the interface to the properties of an Engine.
Important : | This object copies the values you set to it, and returns copies to you when you request them. The only way to change properties os explicitly through the setitem and getitem of the dictionary interface. |
---|
>>> e = get_engine(id)
>>> L = [1,2,3]
>>> e.properties['L'] = L
>>> L == e.properties['L']
True
>>> L.append(99)
>>> L == e.properties['L']
False
Note that getitem copies, so calls to methods of objects do not affect the properties, as seen here:
>>> e.properties[1] = range(2)
>>> print e.properties[1]
[0, 1]
>>> e.properties[1].append(2)
>>> print e.properties[1]
[0, 1]
Bases: IPython.kernel.engineservice.EngineService
An EngineService subclass that defers execute commands to a separate thread.
ThreadedEngineService uses twisted.internet.threads.deferToThread to defer execute requests to a separate thread. GUI frontends may want to use ThreadedEngineService as the engine in an IPython.frontend.frontendbase.FrontEndBase subclass to prevent block execution from blocking the GUI thread.
Wrap self.shell.execute to add extra information to tracebacks