# HG changeset patch # User Goffi # Date 1709656316 -3600 # Node ID 8499b3ad5edb5e2f28d27f1a1fc89f0274722da5 # Parent 919bdf7768d85b379540d068135c88f28cddc5db cli (base): fix exit code transmission when `SystemExit` is catched. diff -r 919bdf7768d8 -r 8499b3ad5edb libervia/cli/base.py --- a/libervia/cli/base.py Tue Mar 05 17:31:56 2024 +0100 +++ b/libervia/cli/base.py Tue Mar 05 17:31:56 2024 +0100 @@ -734,10 +734,10 @@ self.loop = LiberviaCLILoop() try: self.loop.run(self, args, namespace) - except SystemExit: + except SystemExit as e: # The loop is stopped, but we execute it one more time to call `a_quit` which # will call any cleaning method including async ones. - asyncio.get_event_loop().run_until_complete(self.a_quit()) + asyncio.get_event_loop().run_until_complete(self.a_quit(e.code)) @classmethod def run(cls): @@ -804,7 +804,7 @@ if raise_exc: raise QuitException - async def a_quit(self, exit_code=0, raise_exc=True): + async def a_quit(self, exit_code: int=0, raise_exc=True): """Execute async quit callback before actually quitting This method should be prefered to ``quit``, as it executes async quit callbacks