Event

ClusterShell Event handling.

This module contains the base class EventHandler which defines a simple interface to handle events generated by Worker, EventTimer and EventPort objects.

class ClusterShell.Event.EventHandler

ClusterShell EventHandler interface.

Derived class should implement any of the following methods to listen for Worker, EventTimer or EventPort selected events. If not implemented, the default behavior is to do nothing.

ev_start(worker)

Called to indicate that a worker has just started.

Parameters:workerWorker derived 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 your EventHandler derived classes and add the node argument.

New in version 1.7.

Parameters:
  • workerWorker derived object
  • node – 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 your EventHandler derived classes and add the node, sname and msg arguments.

Parameters:
  • workerWorker derived object
  • node – node (or key)
  • sname – stream name
  • msg – 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:
  • workerWorker derived object
  • node – 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 your EventHandler derived classes to add the node and rc arguments.

Parameters:
  • workerWorker derived object
  • node – 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 your EventHandler derived classes to add the timedout argument. Please use this argument instead of the method ev_timeout.

Parameters:
  • workerWorker derived object
  • timedout – boolean set to True if the worker has timed out
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:timerEngineTimer object that is firing