Event¶
ClusterShell Event handling.
This module contains the base class EventHandler which defines a simple interface through methods to handle events coming from ClusterShell I/O Engine clients. Events are generated by Worker, EngineTimer or EnginePort objects.
-
class
ClusterShell.Event.
EventHandler
¶ ClusterShell EventHandler interface.
Derived class should implement the following methods to listen for Worker, EngineTimer or EnginePort chosen events.
-
ev_start
(worker)¶ Called to indicate that a worker has just started.
Parameters: worker – Worker
object
-
ev_pickup
(worker)¶ Called to indicate that a worker command for a specific node (or key) has just started. Called for each node.
Parameters: worker – Worker
objectAvailable worker attributes:
Worker.current_node
- node (or key)
-
ev_read
(worker)¶ Called to indicate that a worker has data to read from a specific node (or key).
Parameters: worker – Worker
objectAvailable worker attributes:
Worker.current_node
- node (or key)Worker.current_msg
- read message
-
ev_error
(worker)¶ Called to indicate that a worker has error to read on stderr from a specific node (or key).
Parameters: worker – Worker
objectAvailable 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.
Note: up to ClusterShell 1.6, this event handler wasn’t implemented. To properly handle ev_written after 1.6, the method signature must consist of the following parameters:
Parameters: - worker –
Worker
object - node – node (or) key
- sname – stream name
- size – amount of bytes that has just been written to node/stream associated with this event
- worker –
-
ev_hup
(worker)¶ Called to indicate that a worker command for a specific node (or key) has just finished. Called for each node.
Parameters: worker – Worker
objectAvailable worker attributes:
Worker.current_node
- node (or key)Worker.current_rc
- command return code
-
ev_timeout
(worker)¶ Called to indicate that a worker has timed out (worker timeout only).
Parameters: worker – Worker
object
-
ev_close
(worker)¶ Called to indicate that a worker has just finished (it may already have failed on timeout).
Parameters: worker – Worker
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 – EnginePort object on which a message has been received
- msg – the message object received
-
ev_timer
(timer)¶ Called to indicate that a timer is firing.
Parameters: timer – EngineTimer
object that is firing
-