From 3d27cc09d987c8bd9a6251e8e9a489320ce97e50 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 15 Apr 2026 21:21:17 +0200 Subject: [PATCH] lib.App.run_sub_commands(): Instantiate as context manager App currently has no hook to close async resources. Call it as context manager, so that __aexit__() gets invoked if run_sub_commands() exits. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/App.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/python/jw/pkg/lib/App.py b/src/python/jw/pkg/lib/App.py index 6cb95777..0e5f888d 100644 --- a/src/python/jw/pkg/lib/App.py +++ b/src/python/jw/pkg/lib/App.py @@ -100,6 +100,12 @@ class App: # export self.__eloop = None self.__own_eloop = False + async def __aenter__(self) ->None: + return self + + async def __aexit__(self, exc_type, exc, tb) -> None: + pass + async def __run(self, argv=None) -> None: try: @@ -188,5 +194,5 @@ class App: # export return ret def run_sub_commands(description = '', name_filter = '^Cmd.*', modules=None, argv=None): # export - app = App(description, name_filter, modules) - return app.run(argv=argv) + with App(description, name_filter, modules) as app: + return app.run(argv=argv)