Event
ClusterShell Event handling.
This module contains the base class EventHandler which defines
a simple interface to handle events generated by Worker,
EngineTimer and EnginePort objects.
- class ClusterShell.Event.EventHandler
ClusterShell EventHandler interface.
Derived class should implement any of the following methods to listen for
Worker,EnginePortorEngineTimerevents. If not implemented, the default behavior is to do nothing.NOTE:
ev_timeout(self, worker)was removed from this class definition in ClusterShell 1.9. For compatibility, it is still called if defined by subclasses. Useev_close()instead and check whether its argumenttimedoutisTrue, which means that theWorkerhas timed out.- ev_start(worker)
Called to indicate that a worker has just started.
- Parameters:
worker --
Workerderived object
- ev_pickup(worker, node)
Called for each node to indicate that a worker command for a specific node (or key) has just started.
Warning
The signature of
EventHandler.ev_pickup()changed in ClusterShell 1.8, please update yourEventHandlerderived classes and add the node argument.New in version 1.7.
- Parameters:
worker --
Workerderived objectnode -- node (or key)
- ev_read(worker, node, sname, msg)
Called to indicate that a worker has data to read from a specific node (or key).
Warning
The signature of
EventHandler.ev_read()changed in ClusterShell 1.8, please update yourEventHandlerderived classes and add the node, sname and msg arguments.- Parameters:
worker --
Workerderived objectnode -- node (or key)
sname -- stream name
msg -- message
- ev_error(worker)
Called to indicate that a worker has error to read on stderr from a specific node (or key).
[DEPRECATED] use ev_read instead and test if sname is 'stderr'
- Parameters:
worker --
Workerobject
Available worker attributes: *
Worker.current_node- node (or key) *Worker.current_errmsg- read error message
- ev_written(worker, node, sname, size)
Called to indicate that some writing has been done by the worker to a node on a given stream. This event is only generated when
write()is previously called on the worker.This handler may be called very often depending on the number of target nodes, the amount of data to write and the block size used by the worker.
New in version 1.7.
- Parameters:
worker --
Workerderived objectnode -- node (or) key
sname -- stream name
size -- amount of bytes that has just been written to node/stream associated with this event
- ev_hup(worker, node, rc)
Called for each node to indicate that a worker command for a specific node has just finished.
Warning
The signature of
EventHandler.ev_hup()changed in ClusterShell 1.8, please update yourEventHandlerderived classes to add the node and rc arguments.- Parameters:
worker --
Workerderived objectnode -- node (or key)
rc -- command return code (or None if the worker doesn't support command return codes)
- ev_close(worker, timedout)
Called to indicate that a worker has just finished.
Warning
The signature of
EventHandler.ev_close()changed in ClusterShell 1.8, please update yourEventHandlerderived classes to add the timedout argument. Please use this argument instead of the old methodev_timeout().- Parameters:
worker --
Workerderived objecttimedout -- boolean set to True if the worker has timed out
- ev_port_start(port)
Called to indicate that a
EnginePortobject has just started.- Parameters:
port --
EnginePortderived object
- ev_msg(port, msg)
Called to indicate that a message has been received on an
EnginePort.Used to deliver messages reliably between tasks.
- Parameters:
port --
EnginePortobject on which a message has been receivedmsg -- the message object received
- ev_timer(timer)
Called to indicate that a timer is firing.
- Parameters:
timer --
EngineTimerobject that is firing