hsm.core.Event

class Event(name, **userdata)

Bases: object

Events trigger actions and transitions.

An event has a name and can carry userdata. The following attributes are set after an event has been dispatched:

Attributes:

_machine

The StateMachine instance that is handling the event.

propagate

An event is propagated from the current state up the state hierarchy until it encounters a handler that can handle the event. To propagate it further (after first handling), set this flag to True in a handler.

Parameters:
  • name (Hashable) – Name of an event. It may be anything as long as it’s hashable.

  • **userdata – All keyword arguments are passed as userdata to handlers.

Example Usage:

state_machine.dispatch(Event('start'))
state_machine.dispatch(Event('start', key='value'))

Methods