Other

Signals

Flask supports signals which allow you to decouple your application; in the Flask-Plugin, you can also use several signals:

The caller of all signals above is the current PluginManager instance, and the only parameter is the plugin Plugin instance being operated.

If you want to enable signaling in Flask, you may need to install the blinker library, for more information see: https://flask.palletsprojects.com/en/2.0.x/signals/

Plugin State Machine

The state of the plugin in Flask-Plugin is an enum.Enum enumeration type that contains the following states.

  • states.PluginStatus.Loaded

  • states.PluginStatus.Running

  • states.PluginStatus.Stopped

  • states.PluginStatus.Unloaded

Plugin status is managed by the finite state machine states.StateMachine; after a plugin is loaded, you can access this state machine instance in Plugin.status.

Generally you don’t need to directly access the state of the plugin, but if you are making extension related to it, you can use the states.StateMachine.allow() method to check whether the current state allows a certain operation.

The ‘operation’ is a string, and the mapping of a tuple of the current state and the operation to the target state is called the state transfer table. The default transfer table of Flask-Plugin is defined in states.TransferTable.

See more information at API References.