Skip to content

Commit 96708a6

Browse files
committed
fix: prevent spurious runtime errors for not awaiting async_ready and async_stopping hooks; update version to 0.0.66
1 parent 3adc8eb commit 96708a6

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

scitrera_app_framework/core/plugins.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

474473
async 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

506504
def schedule_async_shutdown(v: Variables = None, timeout: float = 5.0) -> bool:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="scitrera-app-framework",
8-
version="0.0.65",
8+
version="0.0.66",
99
author="Scitrera LLC",
1010
author_email="open-source-team@scitrera.com",
1111
description="Common Application Framework Code and Utilities",

0 commit comments

Comments
 (0)