Package ClusterShell :: Module Task
[hide private]
[frames] | no frames]

Module Task

source code

ClusterShell Task module.

Simple example of use:

>>> from ClusterShell.Task import task_self, NodeSet
>>>  
>>> # get task associated with calling thread
... task = task_self()
>>> 
>>> # add a command to execute on distant nodes
... task.shell("/bin/uname -r", nodes="tiger[1-30,35]")
<ClusterShell.Worker.Ssh.WorkerSsh object at 0x7f41da71b890>
>>> 
>>> # run task in calling thread
... task.run()
>>> 
>>> # get results
... for output, nodelist in task.iter_buffers():
...     print '%s: %s' % (NodeSet.fromlist(nodelist), output)
...
Classes [hide private]
  TaskException
Base task exception.
  TaskError
Base task error exception.
  TimeoutError
Raised when the task timed out.
  AlreadyRunningError
Raised when trying to resume an already running task.
  TaskMsgTreeError
Raised when trying to access disabled MsgTree.
  Task
The Task class defines an essential ClusterShell object which aims to execute commands in parallel and easily get their results.
Functions [hide private]
 
_getshorthostname()
Get short hostname (host name cut at the first dot)
source code
 
task_self(defaults=None)
Return the current Task object, corresponding to the caller's thread of control (a Task object is always bound to a specific thread).
source code
 
task_wait()
Suspend execution of the calling thread until all tasks terminate, unless all tasks have already terminated.
source code
 
task_terminate()
Destroy the Task instance bound to the current thread.
source code
 
task_cleanup()
Cleanup routine to destroy all created tasks.
source code
Variables [hide private]
  __package__ = 'ClusterShell'
Function Details [hide private]

task_self(defaults=None)

source code 

Return the current Task object, corresponding to the caller's thread of control (a Task object is always bound to a specific thread). This function provided as a convenience is available in the top-level ClusterShell.Task package namespace.

task_wait()

source code 

Suspend execution of the calling thread until all tasks terminate, unless all tasks have already terminated. This function is provided as a convenience and is available in the top-level ClusterShell.Task package namespace.

task_terminate()

source code 

Destroy the Task instance bound to the current thread. A next call to task_self() will create a new Task object. Not to be called from a signal handler. This function provided as a convenience is available in the top-level ClusterShell.Task package namespace.

task_cleanup()

source code 

Cleanup routine to destroy all created tasks. This function provided as a convenience is available in the top-level ClusterShell.Task package namespace. This is mainly used for testing purposes and should be avoided otherwise. task_cleanup() may be called from any threads but not from a signal handler.