AntelopeIO / appbase

Other
1 stars 6 forks source link

Ensure that `plugin_shutdown()` is always called after `plugin_startup()` #25

Closed greg7mdp closed 1 year ago

greg7mdp commented 1 year ago

Even if there was an exception during plugin_startup().

Currently, because a plugin is stored in the running_plugins list only after plugin_startup(), it would not be present if it throws during plugin_startup(), and as a consequence plugin_shutdown() would not be called on this plugin.

We need to make sure that plugin_shutdown() is called regardless of whether plugin_startup() completed successfully or not. That way, plugins can rest assured that whatever thread_pool or timer they started during plugin_startup() will be cleaned up, and no lambda referencing the plugin will be executed after the plugin is destroyed by the framework.

see parent issue https://github.com/AntelopeIO/spring/issues/842.