@@ -461,14 +461,13 @@ async def async_plugins_ready(v: Variables = None, *, capture_loop: bool = True)
461461 continue
462462
463463 try :
464- value = _get_plugin_value (plugin , v )
465- coro = plugin .async_ready (v , plugin .get_logger (v ), value )
466- if coro is not None and not plugin ._async_ready_called :
464+ if not plugin ._async_ready_called :
465+ await plugin .async_ready (v , plugin .get_logger (v ), value = _get_plugin_value (plugin , v ))
467466 logger .debug ('SAF: async_ready for plugin: %s' , plugin .name ())
468- await coro
469467 plugin ._async_ready_called = True
470468 except Exception as e :
471469 logger .warning ('Exception in async_ready for plugin "%s": %s' , plugin .name (), e )
470+ plugin ._async_ready_called = True # prevent duplicate invocation even on failure cases
472471
473472
474473async def async_plugins_stopping (v : Variables = None ):
@@ -493,14 +492,13 @@ async def async_plugins_stopping(v: Variables = None):
493492 continue
494493
495494 try :
496- value = _get_plugin_value (plugin , v )
497- coro = plugin .async_stopping (v , plugin .get_logger (v ), value )
498- if coro is not None and not plugin ._async_stopping_called :
495+ if not plugin ._async_stopping_called :
496+ await plugin .async_stopping (v , plugin .get_logger (v ), value = _get_plugin_value (plugin , v ))
499497 logger .debug ('SAF: async_stopping for plugin: %s' , plugin .name ())
500- await coro
501- plugin ._async_stopping_called = True
498+ plugin ._async_stopping_called = True # prevent duplicate invocation even on failure cases
502499 except Exception as e :
503500 logger .warning ('Exception in async_stopping for plugin "%s": %s' , plugin .name (), e )
501+ plugin ._async_stopping_called = True # prevent duplicate invocation even on failure cases
504502
505503
506504def schedule_async_shutdown (v : Variables = None , timeout : float = 5.0 ) -> bool :
0 commit comments