| Trees | Indices | Help |
|
|---|
|
|
Always bound to a thread, the Task class allows you to execute commands in parallel and get their results.
To create a task in a new thread:
>>> task = Task()
To create or get the instance of the task associated with the thread object thr (threading.Thread):
>>> task = Task(thread=thr)
Add a command to execute locally within task with:
>>> task.shell("/bin/hostname")
Add a command to execute to a distant node within task with:
>>> task.shell("/bin/hostname", nodes="tiger[1-20]")
Run task in its associated thread (will block only if the calling thread is the task associated thread):
>>> task.resume()
|
|||
|
_SyncMsgHandler Special task control port event handler. |
|||
|
tasksyncmethod Class encapsulating a function that checks if the calling task is running or is the current task, and allowing it to be used as a decorator making the wrapped task method thread-safe. |
|||
|
_SuspendCondition Special class to manage task suspend condition. |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
|
|||
|
|||
| a new object with type S, a subtype of T |
|
||
|
|||
_std_default =
|
|||
_std_info =
|
|||
_tasks =
|
|||
_taskid_max = 0
|
|||
_task_lock = threading.Lock()
|
|||
|
|||
| excepthook | |||
|
Inherited from |
|||
|
|||
For task bound to a specific thread, this class acts like a "thread singleton", so new style class is used and new object are only instantiated if needed.
|
Initialize a Task, creating a new thread if needed.
|
Default excepthook for a newly Task. When an exception is raised and uncaught on Task thread, excepthook is called, which is default_excepthook by default. Once excepthook overriden, you can still call default_excepthook if needed. |
Default excepthook for a newly Task. When an exception is raised and uncaught on Task thread, excepthook is called, which is default_excepthook by default. Once excepthook overriden, you can still call default_excepthook if needed. |
Return per-task value for key from the "default" dictionary. See set_default() for a list of reserved task default_keys. |
Set task value for specified key in the dictionary "default". Users may store their own task-specific key, value pairs using this method and retrieve them with default(). Task default_keys are:
Threading considerationsUnlike set_info(), when called from the task's thread or not, set_default() immediately updates the underlying dictionary in a thread-safe manner. This method doesn't wake up the engine when called. |
Return per-task information. See set_info() for a list of reserved task info_keys. |
Set task value for a specific key information. Key, value pairs can be passed to the engine and/or workers. Users may store their own task-specific info key, value pairs using this method and retrieve them with info(). Task info_keys are:
Threading considerationsUnlike set_default(), the underlying info dictionary is only modified from the task's thread. So calling set_info() from another thread leads to queueing the request for late apply (at run time) using the task dispatch port. When received, the request wakes up the engine when the task is running and the info dictionary is then updated.
|
Schedule a shell command for local or distant execution. Local usage:
task.shell(command [, key=key] [, handler=handler]
[, timeout=secs] [, autoclose=enable_autoclose]
[, stderr=enable_stderr])
Distant usage:
task.shell(command, nodes=nodeset [, handler=handler]
[, timeout=secs], [, autoclose=enable_autoclose]
[, strderr=enable_stderr])
|
Add an EnginePort instance to Engine (private method).
|
Remove a port from Engine (private method).
|
Create a new task port. A task port is an abstraction object to deliver messages reliably between tasks. Basic rules:
If handler is set to a valid EventHandler object, the port is a send-once port, ie. a message sent to this port generates an ev_msg event notification issued the port's task. If handler is not set, the task can only receive messages on the port by calling port.msg_recv(). |
Create task's timer.
|
Schedule a worker for execution. Only useful for manually instantiated workers.
|
Resume task. If task is task_self(), workers are executed in the calling thread so this method will block until workers have finished. This is always the case for a single-threaded application (eg. which doesn't create other Task() instance than task_self()). Otherwise, the current thread doesn't block. In that case, you may then want to call task_wait() to wait for completion. |
|
Suspend task execution. This method may be called from another task (thread-safe). The function returns False if the task cannot be suspended (eg. it's not running), or returns True if the task has been successfully suspended. To resume a suspended task, use task.resume(). |
|
Abort a task. Aborting a task removes (and stops when needed) all workers. If optional parameter kill is True, the task object is unbound from the current thread, so calling task_self() creates a new Task object. |
Iterate over timed out keys (ie. nodes) for a specific worker. |
Get buffer for a specific key. When the key is associated to multiple workers, the resulting buffer will contain all workers content that may overlap. This method returns an empty buffer if key is not found in any workers. |
Get buffer for a specific key. When the key is associated to multiple workers, the resulting buffer will contain all workers content that may overlap. This method returns an empty buffer if key is not found in any workers. |
Get error buffer for a specific key. When the key is associated to multiple workers, the resulting buffer will contain all workers content that may overlap. This method returns an empty error buffer if key is not found in any workers. |
Get error buffer for a specific key. When the key is associated to multiple workers, the resulting buffer will contain all workers content that may overlap. This method returns an empty error buffer if key is not found in any workers. |
Return return code for a specific key. When the key is associated to multiple workers, return the max return code from these workers. Raises a KeyError if key is not found in any finished workers. |
Return return code for a specific key. When the key is associated to multiple workers, return the max return code from these workers. Raises a KeyError if key is not found in any finished workers. |
Get max return code encountered during last run. How retcodes workIf the process exits normally, the return code is its exit status. If the process is terminated by a signal, the return code is 128 + signal number. |
Iterate over buffers, returns a tuple (buffer, keys). For remote workers (Ssh), keys are list of nodes. In that case, you should use NodeSet.fromlist(keys) to get a NodeSet instance (which is more convenient and efficient): Optional parameter match_keys add filtering on these keys. Usage example: >>> for buffer, nodelist in task.iter_buffers(): ... print NodeSet.fromlist(nodelist) ... print buffer |
Iterate over error buffers, returns a tuple (buffer, keys). See iter_buffers(). |
Iterate over return codes, returns a tuple (rc, keys). Optional parameter match_keys add filtering on these keys. How retcodes workIf the process exits normally, the return code is its exit status. If the process is terminated by a signal, the return code is 128 + signal number. |
Return the number of timed out "keys" (ie. nodes). |
Iterate over timed out keys (ie. nodes). |
Class method that blocks calling thread until all tasks have finished (from a ClusterShell point of view, for instance, their task.resume() return). It doesn't necessarly mean that associated threads have finished. |
|
|||
_std_default
|
_std_info
|
|
|||
excepthook
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Jul 27 21:53:20 2010 | http://epydoc.sourceforge.net |