From 1827e5434e8e2a2976df69ef39059c5f10b12206 Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Mon, 26 Sep 2016 10:51:27 +0700 Subject: [PATCH] Using sys.exit(main()) instead of main() TrivialFix: Similar [1] in Kolla project As we known, Exceptions are raised by the sys.exit() function. When they are not handled, no stack traceback is printed in the Python interpreter. Therefore, when using sys.exit(main()) instead of main() may be more readable and reasonable. [1] https://review.openstack.org/#/c/349353/ Change-Id: Ic71d4bfb1085c68ea9eb7e1382e7263a81634ad1 --- mistral/cmd/launch.py | 2 +- mistral/db/sqlalchemy/migration/cli.py | 3 ++- mistral/engine/rpc_backend/kombu/examples/client.py | 4 +++- mistral/engine/rpc_backend/kombu/examples/server.py | 4 +++- tools/sync_db.py | 4 +++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/mistral/cmd/launch.py b/mistral/cmd/launch.py index c5ab76d64..422f28cc9 100644 --- a/mistral/cmd/launch.py +++ b/mistral/cmd/launch.py @@ -247,4 +247,4 @@ def main(): if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/mistral/db/sqlalchemy/migration/cli.py b/mistral/db/sqlalchemy/migration/cli.py index 2df9a0720..e7f1e3cb3 100644 --- a/mistral/db/sqlalchemy/migration/cli.py +++ b/mistral/db/sqlalchemy/migration/cli.py @@ -21,6 +21,7 @@ from alembic import util as alembic_u from oslo_config import cfg from oslo_utils import importutils import six +import sys from mistral.services import action_manager from mistral.services import workflows @@ -129,4 +130,4 @@ def main(): CONF.command.func(config, CONF.command.name) if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/mistral/engine/rpc_backend/kombu/examples/client.py b/mistral/engine/rpc_backend/kombu/examples/client.py index 7bdf3339c..bf4f024c6 100644 --- a/mistral/engine/rpc_backend/kombu/examples/client.py +++ b/mistral/engine/rpc_backend/kombu/examples/client.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys + from mistral.engine.rpc_backend.kombu import kombu_client @@ -39,4 +41,4 @@ def main(): if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/mistral/engine/rpc_backend/kombu/examples/server.py b/mistral/engine/rpc_backend/kombu/examples/server.py index 119d5abc2..ceb828807 100644 --- a/mistral/engine/rpc_backend/kombu/examples/server.py +++ b/mistral/engine/rpc_backend/kombu/examples/server.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys + from mistral.engine.rpc_backend.kombu import kombu_server @@ -48,4 +50,4 @@ def main(): if __name__ == '__main__': - main() + sys.exit(main()) diff --git a/tools/sync_db.py b/tools/sync_db.py index 6590cb950..1f84db026 100644 --- a/tools/sync_db.py +++ b/tools/sync_db.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys + import keystonemiddleware.opts as keystonemw_opts from oslo_config import cfg from oslo_log import log as logging @@ -49,4 +51,4 @@ def main(): if __name__ == '__main__': - main() + sys.exit(main())