From f807eef2a37aae7724670c688feb05a8302c9c29 Mon Sep 17 00:00:00 2001 From: DongZe Li <9546726@qq.com> Date: Mon, 15 Mar 2021 16:43:08 +0800 Subject: [PATCH] Stop propgagating signal to coordinator subprocess when launching locally (#190) --- coordinator/gscoordinator/coordinator.py | 9 ++++++++- python/graphscope/client/session.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/coordinator/gscoordinator/coordinator.py b/coordinator/gscoordinator/coordinator.py index 661042bc284a..5c1fd0c795b4 100644 --- a/coordinator/gscoordinator/coordinator.py +++ b/coordinator/gscoordinator/coordinator.py @@ -944,8 +944,15 @@ def launch_graphscope(): logger.info("Coordinator server listen at 0.0.0.0:%d", args.port) server.start() + + # handle SIGTERM signal + def terminate(signum, frame): + del coordinator_service_servicer # noqa: F821 + + signal.signal(signal.SIGTERM, terminate) + try: - # Grpc has handled SIGINT/SIGTERM + # Grpc has handled SIGINT server.wait_for_termination() except KeyboardInterrupt: del coordinator_service_servicer diff --git a/python/graphscope/client/session.py b/python/graphscope/client/session.py index 6f00bd10b3ec..611c434c3bdd 100755 --- a/python/graphscope/client/session.py +++ b/python/graphscope/client/session.py @@ -1109,8 +1109,11 @@ def _launch_coordinator_on_local(config_params): env = os.environ.copy() env["PYTHONUNBUFFERED"] = "TRUE" + # Param `start_new_session=True` is for putting child process to a new process group + # so it won't get the signals from parent. process = subprocess.Popen( cmd, + start_new_session=True, cwd=COORDINATOR_HOME, universal_newlines=True, encoding="utf-8",