From d35a5588cd69f96066d7c6052ac05ecb3329f6d7 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 5 Jul 2025 12:27:11 +0200 Subject: [PATCH] Cmds.__run(): Don't exit(0) WSGI doesn't like sys.exit() being called, so avoid it. Two cases need to be taken into consideration: 1. No exception thrown by self.args.func() The variable exit_status is zero, we can check that and _not_ call sys.exit() 2. Exception thrown by self.args.func() In that case, the exception should be raised, to be caught by WSGI / ASGI whatever to do what they want with it. The code calling sys.exit() is never reached. Hence, we need to add --backtrace to the invocation options. Signed-off-by: Jan Lindemann --- tools/python/jwutils/Cmds.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/python/jwutils/Cmds.py b/tools/python/jwutils/Cmds.py index 6f71705..4db9604 100644 --- a/tools/python/jwutils/Cmds.py +++ b/tools/python/jwutils/Cmds.py @@ -136,7 +136,8 @@ class Cmds: # export slog(NOTICE, f'Writing profile statistics to {self.args.write_profile}') pr.dump_stats(self.args.write_profile) - sys.exit(exit_status) + if exit_status: + sys.exit(exit_status) def __del__(self): if self.__own_eloop: