Gaffer events

Many events happend in gaffer.

Manager events

Manager events have the following format:

  "event": "<nameofevent">>,
  "name": "<templatename>"
  • create: a process template is created
  • start: a process template start to launch OS processes
  • stop: all OS processes of a process template are stopped
  • restart: all processes of a process template are restarted
  • update: a process template is updated
  • delete: a process template is deleted
  • spawn: a new process is spawned
  • reap: a process is reaped
  • exit: a process exited
  • stop_pid: a process has been stopped

Processes events

All processes’ events are prefixed by proc.<name> to make the pattern matching easier, where <name> is the name of the process template

Events are:

  • proc.<name>.start : the template <name> start to spawn processes

  • proc.<name>.spawn : one OS process using the process <name> template is spawned. Message is:

      "event": "proc.<name>.spawn">>,
      "name": "<name>",
      "detach": false,
      "pid": int


    pid is the internal pid

  • proc.<name>.exit: one OS process of the <name> template has exited. Message is:

      "event": "proc.<name>.exit">>,
      "name": "<name>",
      "pid": int,
      "exit_code": int,
      "term_signal": int
  • proc.<name>.stop: all OS processes in the template <name> are stopped.

  • proc.<name>.stop_pid: One OS process of the template <name> is stopped. Message is:

      "event": "proc.<name>.stop_pid">>,
      "name": "<name>",
      "pid": int
  • proc.<name>.stop_pid: One OS process of the template <name> is reapped. Message is:

      "event": "proc.<name>.reap">>,
      "name": "<name>",
      "pid": int

The events Module

This module offeres a common way to susbscribe and emit events. All events in gaffer are using.

Example of usage

event = EventEmitter()

# subscribe to all events with the pattern a.*
event.subscribe("a", subscriber)

# subscribe to all events "a.b"
event.subscribe("a.b", subscriber2)

# subscribe to all events (wildcard)
event.subscribe(".", subscriber3)

# publish an event
event.publish("a.b", arg, namedarg=val)

In this example all subscribers will be notified of the event. A subscriber is just a callable (event, *args, **kwargs)


class, max_size=200)[source]

Bases: object

Many events happend in gaffer. For example a process will emist the events “start”, “stop”, “exit”.

This object offer a common interface to all events emitters


close the event

This function clear the list of listeners and stop all idle callback

publish(evtype, *args, **kwargs)[source]

emit an event evtype

The event will be emitted asynchronously so we don’t block here

subscribe(evtype, listener, once=False)[source]

subcribe to an event

subscribe_once(evtype, listener)[source]

subscribe to event once. Once the evennt is triggered we remove ourself from the list of listenerrs

unsubscribe(evtype, listener, once=False)[source]

unsubscribe from an event


unsubscribe all listeners from a list of events

unsubscribe_once(evtype, listener)[source]

Table Of Contents

Previous topic

process Module

Next topic


This Page