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, EnginePort or EngineTimer events. 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. Use ev_close() instead and check whether its argument timedout is True, which means that the Worker has timed out.

ev_start(worker)

Called to indicate that a worker has just started.

Parameters:worker -- Worker 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:
  • worker -- Worker 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:
  • worker -- Worker derived object
  • node -- 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 -- Worker object

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 -- Worker 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:
  • worker -- Worker 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 old method ev_timeout().

Parameters:
  • worker -- Worker derived object
  • timedout -- boolean set to True if the worker has timed out
ev_port_start(port)

Called to indicate that a EnginePort object has just started.

Parameters:port -- EnginePort derived 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