Many events happend in gaffer.
Manager events have the following format:
{
"event": "<nameofevent">>,
"name": "<templatename>"
}
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
}
Note
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
}
This module offeres a common way to susbscribe and emit events. All events in gaffer are using.
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)
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
emit an event evtype
The event will be emitted asynchronously so we don’t block here