Inheritance diagram for IPython.kernel.task:
Task farming representation of the ControllerService.
Bases: object
Common fuctionality for all objects implementing ITask.
Make a generic task.
Parameters: |
|
---|
Process a task result.
This is the default process_result that just returns the raw result or a Failure.
Bases: object
A basic First-In-First-Out (Queue) Scheduler.
This is the default Scheduler for the TaskController. See the docstrings for IScheduler for interface details.
Bases: zope.interface.Interface
This interface provides a generic definition of what constitutes a task.
There are two sides to a task. First a task needs to take input from a user to determine what work is performed by the task. Second, the task needs to have the logic that knows how to turn that information info specific calls to a worker, through the IQueuedEngine interface.
Many method in this class get two things passed to them: a Deferred and an IQueuedEngine implementer. Such methods should register callbacks on the Deferred that use the IQueuedEngine to accomplish something. See the existing task objects for examples.
Bases: IPython.kernel.controllerservice.IControllerBase
The Task based interface to a ControllerService object
This adapts a ControllerService to the ITaskController interface.
Bases: IPython.kernel.task.FIFOScheduler
A Last-In-First-Out (Stack) Scheduler.
This scheduler should naively reward fast engines by giving them more jobs. This risks starvation, but only in cases with low load, where starvation does not really matter.
Bases: IPython.kernel.task.BaseTask
A task that consists of a function and arguments.
Create a task based on a function, args and kwargs.
This is a simple type of task that consists of calling: function(*args, **kwargs) and wrapping the result in a TaskResult.
The return value of the function, or a Failure wrapping an exception is the task result for this type of task.
Bases: object
A dict like object for holding the results of a task.
The result namespace object for use in TaskResult objects as tr.ns. It builds an object from a dictionary, such that it has attributes according to the key,value pairs of the dictionary.
This works by calling setattr on ALL key,value pairs in the dict. If a user chooses to overwrite the __repr__ or __getattr__ attributes, they can. This can be a bad idea, as it may corrupt standard behavior of the ns object.
Examples
>>> ns = ResultNS({'a':17,'foo':range(3)})
>>> print ns
NS{'a': 17, 'foo': [0, 1, 2]}
>>> ns.a
17
>>> ns['foo']
[0, 1, 2]
Bases: IPython.kernel.task.BaseTask
A task that consists of a string of Python code to run.
Create a task based on a Python expression and variables
This type of task lets you push a set of variables to the engines namespace, run a Python string in that namespace and then bring back a different set of Python variables as the result.
Because this type of task can return many results (through the pull keyword argument) it returns a special TaskResult object that wraps the pulled variables, statistics about the run and any exceptions raised.
Bases: IPython.kernel.controllerservice.ControllerAdapterBase
The Task based interface to a Controller object.
If you want to use a different scheduler, just subclass this and set the SchedulerClass member to the class of your chosen scheduler.
A basic First-In-First-Out (Queue) Scheduler.
This is the default Scheduler for the TaskController. See the docstrings for IScheduler for interface details.
Clear all previously run tasks from the task controller.
This is needed because the task controller keep all task results in memory. This can be a problem is there are many completed tasks. Users should call this periodically to clean out these cached task results.
Readmit a worker to the scheduler.
This is outside taskCompleted because of the failurePenalty being implemented through reactor.callLater.
Bases: object
An object for returning task results for certain types of tasks.
This object encapsulates the results of a task. On task success it will have a keys attribute that will have a list of the variables that have been pulled back. These variables are accessible as attributes of this class as well. On success the failure attribute will be None.
In task failure, keys will be empty, but failure will contain the failure object that encapsulates the remote exception. One can also simply call the raise_exception method of this class to re-raise any remote exception in the local session.
The TaskResult has a .ns member, which is a property for access to the results. If the Task had pull=[‘a’, ‘b’], then the Task Result will have attributes tr.ns.a, tr.ns.b for those values. Accessing tr.ns will raise the remote failure if the task failed.
The engineid attribute should have the engineid of the engine that ran the task. But, because engines can come and go, the engineid may not continue to be valid or accurate.
The taskid attribute simply gives the taskid that the task is tracked under.
Bases: object
Adapt an IQueuedEngine to an IWorker object
Run task in worker’s namespace.
This takes a task and calls methods on the task that actually cause self.queuedEngine to do the task. See the methods of ITask for more information about how these methods are called.
Parameters: | task : a Task object |
---|---|
Returns: | Deferred to a tuple of (success, result) where success if a boolean that signifies success or failure and result is the task result. |