Worker is an essential base class for the ClusterShell library. The
goal of a worker object is to execute a common work on a single or
several targets (abstract notion) in parallel. Concret targets and also
the notion of local or distant targets are managed by Worker's subclasses
(for example, see the DistantWorker base class).
A configured Worker object is associated to a specific ClusterShell
Task, which can be seen as a single-threaded Worker supervisor. Indeed,
the work to be done is executed in parallel depending on other Workers
and Task's current paramaters, like current fanout value.
ClusterShell is designed to write event-driven applications, and the
Worker class is key here as Worker objects are passed as parameter of
most event handlers (see the ClusterShell.Event.EventHandler class).
The following public object variables are defined on some events, so
you may find them useful in event handlers:
|
|
|
|
|
_task_bound_check(self)
Helper method to check that worker is bound to a task. |
source code
|
|
|
_engine_clients(self)
Return a list of underlying engine clients. |
source code
|
|
|
_on_start(self,
key)
Called on command start. |
source code
|
|
|
_on_rc(self,
key,
rc)
Command return code received. |
source code
|
|
|
_on_written(self,
key,
bytes_count,
sname)
Notification of bytes written. |
source code
|
|
|
|
|
|
|
did_timeout(self)
Return whether this worker has aborted due to timeout. |
source code
|
|
|
read(self,
node=None,
sname=' stdout ' )
Read worker stream buffer. |
source code
|
|
|
abort(self)
Abort processing any action by this worker. |
source code
|
|
|
flush_buffers(self)
Flush any messages associated to this worker. |
source code
|
|
|
flush_errors(self)
Flush any error messages associated to this worker. |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|